{"id":20989884,"url":"https://github.com/iddm/diesel-chrono-duration","last_synced_at":"2026-05-22T05:33:50.847Z","repository":{"id":57619062,"uuid":"121761910","full_name":"iddm/diesel-chrono-duration","owner":"iddm","description":"Adds chrono duration support for the diesel ORM","archived":false,"fork":false,"pushed_at":"2023-12-05T18:12:01.000Z","size":11,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-28T06:55:06.530Z","etag":null,"topics":["chrono","diesel","duration","rust"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iddm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"iddm"}},"created_at":"2018-02-16T14:47:04.000Z","updated_at":"2023-12-05T18:12:05.000Z","dependencies_parsed_at":"2025-01-20T08:08:06.858Z","dependency_job_id":"cbff2d7a-6961-4541-a761-30fc969df0d1","html_url":"https://github.com/iddm/diesel-chrono-duration","commit_stats":null,"previous_names":["iddm/diesel-chrono-duration","vityafx/diesel-chrono-duration"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iddm%2Fdiesel-chrono-duration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iddm%2Fdiesel-chrono-duration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iddm%2Fdiesel-chrono-duration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iddm%2Fdiesel-chrono-duration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iddm","download_url":"https://codeload.github.com/iddm/diesel-chrono-duration/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243401492,"owners_count":20285052,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chrono","diesel","duration","rust"],"created_at":"2024-11-19T06:26:35.547Z","updated_at":"2025-12-29T05:40:46.200Z","avatar_url":"https://github.com/iddm.png","language":"Rust","funding_links":["https://github.com/sponsors/iddm"],"categories":[],"sub_categories":[],"readme":"# diesel-chrono-duration\n[![](https://meritbadge.herokuapp.com/diesel-chrono-duration)](https://crates.io/crates/diesel-chrono-duration) [![](https://travis-ci.org/iddm/diesel-chrono-duration.svg?branch=master)](https://travis-ci.org/iddm/diesel-chrono-duration) ![CI](https://github.com/iddm/diesel-chrono-duration/workflows/CI/badge.svg) [![](https://docs.rs/diesel-chrono-duration/badge.svg)](https://docs.rs/diesel-chrono-duration)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)\n\n\nThis crate adds support for the [`chrono::Duration`](https://docs.rs/chrono/0.4.0/chrono/struct.Duration.html) type into the [`diesel` ORM](http://diesel.rs/).\n\n## Why\n\nDiesel crate has a policy of including only such type implementations which can be represented as is in the SQL types. `chrono::Duration` does not have a direct 1-to-1 mapping in both the `SQLite` and `PostgreSQL`.\n\n## How\n\nThe `chrono::Duration` type stores its value as `i64` number. This is exactly 8 bytes and such types are `BigInteger` and `BigInt`. So, the `ToSql` and `FromSql` traits implementation simply uses `chrono::Duration`'s inner\n`i64` value.\n\n## Usage\n\nTo implement this we added `ChronoDurationProxy` type which is just a strong type as defined as:\n\n```rust\npub struct ChronoDurationProxy(pub chrono::Duration);\n```\n\nIn your table model you use it instead of `chrono::Duration`:\n\n```rust\nextern crate diesel_chrono_duration;\n\nuse diesel_chrono_duration::ChronoDurationProxy;\n\n#[derive(Debug, Clone, Queryable, Insertable)]\n#[table_name = \"sometable\"]\npub struct SomeTable {\n    /// The ID of the record in the table.\n    pub id: i32,\n    /// Some duration\n    pub duration: ChronoDurationProxy,\n}\n```\n\nLater, when you want to use it's value as `chrono::Duration` you have these options:\n\n- `*duration` returns a reference to the inner `chrono::Duration` object. It is done by the `Deref` trait.\n- `\u0026duration` also returns a reference to the inner `chrono::Duration` object. It is done by the `AsRef` trait.\n- `duration.0` as in usual rust.\n\n## Contribute\n\nThe project is very simple and small but all contributions are \"please make a contribution\". Thanks in advance.\n\n## License\n\nThis project is [licensed under the MIT license](https://github.com/iddm/diesel-chrono-duration/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiddm%2Fdiesel-chrono-duration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiddm%2Fdiesel-chrono-duration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiddm%2Fdiesel-chrono-duration/lists"}