| Crates.io | datetime-rs-codegen |
| lib.rs | datetime-rs-codegen |
| version | 1.11.3 |
| created_at | 2025-08-04 23:47:33.500145+00 |
| updated_at | 2025-09-08 23:18:27.161753+00 |
| description | Date and time |
| homepage | |
| repository | https://github.com/lukesneeringer/datetime-rs |
| max_upload_size | |
| id | 1781317 |
| size | 10,534 |
The datetime crate provides a simple, easy-to-use DateTime struct (and corresponding macro).
DateTime provides storage for a date and time, and optionally a time zone (if the tz feature is
enabled).
The underlying storage is a Unix timestamp, so DateTime objects are comparable (even when in
different time zones). Additonally, if you don't need the concept of time zones (e.g. because you
can assume one), you can leave the tz feature off and not take the baggage.
A DateTime with no time zone specified behaves identically to UTC.
Making a DateTime:
use datetime::DateTime;
let dt = DateTime::ymd(2012, 4, 21).hms(11, 0, 0).build();
You can also use the datetime! macro to get a syntax resembling a date literal:
use datetime::datetime;
let dt = datetime! { 2012-04-21 11:00:00 };
datetime-rs ships with the following features:
diesel-pg: Enables interop with PostgreSQL TIMESTAMP columns using Diesel.log: Adds a log::kv::ToValue implementation.serde: Enables serialization and desearialization with serde. (Enabled by default.)tz: Enables support for time-zone-aware date construction.