Chrono: Date and Time for Rust
It aims to be a feature-complete superset of the time library. In particular,
- Chrono strictly adheres to ISO 8601.
- Chrono is timezone-aware by default, with separate timezone-naive types.
- Chrono is space-optimal and (while not being the primary goal) reasonably efficient.
There were several previous attempts to bring a good date and time library to Rust, which Chrono builds upon and should acknowledge:
- Initial research on the wiki
- Dietrich Epp's datetime-rs
- Luis de Bethencourt's rust-datetime
Only proleptic Gregorian calendar (i.e. extended to support older dates) is supported. Be very careful if you really have to deal with pre-20C dates, they can be in Julian or others.
Date types are limited in about +/- 262,000 years from the common epoch. Time types are limited in the nanosecond accuracy.
Leap seconds are supported in the representation but
Chrono doesn't try to make use of them.
(The main reason is that leap seconds are not really predictable.)
Almost every operation over the possible leap seconds will ignore them.
NaiveDateTime with the implicit TAI (International Atomic Time) scale
if you want.
Chrono inherently does not support an inaccurate or partial date and time representation.
Any operation that can be ambiguous will return
None in such cases.
For example, "a month later" of 2014-01-30 is not well-defined
Utc.ymd_opt(2014, 1, 30).unwrap().with_month(2) returns
Non ISO week handling is not yet supported. For now you can use the chrono_ext crate (sources).
Advanced time zone handling is not yet supported. For now you can try the Chrono-tz crate instead.