|
1 |
| -[Chrono][docsrs]: Date and Time for Rust |
| 1 | +[Chrono][docsrs]: Timezone-aware date and time handling |
2 | 2 | ========================================
|
3 | 3 |
|
4 | 4 | [![Chrono GitHub Actions][gh-image]][gh-checks]
|
|
15 | 15 | [gitter-image]: https://badges.gitter.im/chrono-rs/chrono.svg
|
16 | 16 | [gitter]: https://gitter.im/chrono-rs/chrono
|
17 | 17 |
|
18 |
| -It aims to be a feature-complete superset of |
19 |
| -the [time](https://github.com/rust-lang-deprecated/time) library. |
20 |
| -In particular, |
| 18 | +Chrono aims to provide all functionality needed to do correct operations on dates and times in the |
| 19 | +[proleptic Gregorian calendar](https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar): |
21 | 20 |
|
22 |
| -* Chrono strictly adheres to ISO 8601. |
23 |
| -* Chrono is timezone-aware by default, with separate timezone-naive types. |
24 |
| -* Chrono is space-optimal and (while not being the primary goal) reasonably efficient. |
| 21 | +* The [`DateTime`](https://docs.rs/chrono/latest/chrono/struct.DateTime.html) type is timezone-aware |
| 22 | + by default, with separate timezone-naive types. |
| 23 | +* Operations that may produce an invalid or ambiguous date and time return `Option` or |
| 24 | + [`LocalResult`](https://docs.rs/chrono/latest/chrono/offset/enum.LocalResult.html). |
| 25 | +* Configurable parsing and formatting with an `strftime` inspired date and time formatting syntax. |
| 26 | +* The [`Local`](https://docs.rs/chrono/latest/chrono/offset/struct.Local.html) timezone works with |
| 27 | + the current timezone of the OS. |
| 28 | +* Types and operations are implemented to be reasonably efficient. |
25 | 29 |
|
26 |
| -There were several previous attempts to bring a good date and time library to Rust, |
27 |
| -which Chrono builds upon and should acknowledge: |
| 30 | +Timezone data is not shipped with chrono by default to limit binary sizes. Use the companion crate |
| 31 | +[Chrono-TZ](https://crates.io/crates/chrono-tz) or [`tzfile`](https://crates.io/crates/tzfile) for |
| 32 | +full timezone support. |
28 | 33 |
|
29 |
| -* [Initial research on |
30 |
| - the wiki](https://github.com/rust-lang/rust-wiki-backup/blob/master/Lib-datetime.md) |
31 |
| -* Dietrich Epp's [datetime-rs](https://github.com/depp/datetime-rs) |
32 |
| -* Luis de Bethencourt's [rust-datetime](https://github.com/luisbg/rust-datetime) |
| 34 | +## Documentation |
| 35 | + |
| 36 | +See [docs.rs](https://docs.rs/chrono/latest/chrono/) for the API reference. |
33 | 37 |
|
34 | 38 | ## Limitations
|
35 | 39 |
|
36 |
| -Only proleptic Gregorian calendar (i.e. extended to support older dates) is supported. |
37 |
| -Be very careful if you really have to deal with pre-20C dates, they can be in Julian or others. |
| 40 | +* Only the proleptic Gregorian calendar (i.e. extended to support older dates) is supported. |
| 41 | +* Date types are limited to about +/- 262,000 years from the common epoch. |
| 42 | +* Time types are limited to nanosecond accuracy. |
| 43 | +* Leap seconds can be represented, but Chrono does not fully support them. |
| 44 | + See [Leap Second Handling](https://docs.rs/chrono/latest/chrono/naive/struct.NaiveTime.html#leap-second-handling). |
| 45 | + |
| 46 | +## Crate features |
| 47 | + |
| 48 | +Default features: |
| 49 | + |
| 50 | +* `alloc`: Enable features that depend on allocation (primarily string formatting) |
| 51 | +* `std`: Enables functionality that depends on the standard library. This is a superset of `alloc` |
| 52 | + and adds interoperation with standard library types and traits. |
| 53 | +* `clock`: Enables reading the system time (`now`) and local timezone (`Local`). |
| 54 | +* `wasmbind`: Interface with the JS Date API for the `wasm32` target. |
| 55 | + |
| 56 | +Optional features: |
| 57 | + |
| 58 | +* `serde`: Enable serialization/deserialization via serde. |
| 59 | +* `rkyv`: Enable serialization/deserialization via rkyv. |
| 60 | +* `rustc-serialize`: Enable serialization/deserialization via rustc-serialize (deprecated). |
| 61 | +* `arbitrary`: construct arbitrary instances of a type with the Arbitrary crate. |
| 62 | +* `unstable-locales`: Enable localization. This adds various methods with a `_localized` suffix. |
| 63 | + The implementation and API may change or even be removed in a patch release. Feedback welcome. |
| 64 | + |
| 65 | +## Rust version requirements |
| 66 | + |
| 67 | +The Minimum Supported Rust Version (MSRV) is currently **Rust 1.56.0**. |
38 | 68 |
|
39 |
| -Date types are limited in about +/- 262,000 years from the common epoch. |
40 |
| -Time types are limited in the nanosecond accuracy. |
| 69 | +The MSRV is explicitly tested in CI. It may be bumped in minor releases, but this is not done |
| 70 | +lightly. |
41 | 71 |
|
42 |
| -[Leap seconds are supported in the representation but |
43 |
| -Chrono doesn't try to make use of them](https://docs.rs/chrono/0.5/chrono/naive/struct.NaiveTime.html#leap-second-handling). |
44 |
| -(The main reason is that leap seconds are not really predictable.) |
45 |
| -Almost *every* operation over the possible leap seconds will ignore them. |
46 |
| -Consider using `NaiveDateTime` with the implicit TAI (International Atomic Time) scale |
47 |
| -if you want. |
| 72 | +## License |
48 | 73 |
|
49 |
| -Chrono inherently does not support an inaccurate or partial date and time representation. |
50 |
| -Any operation that can be ambiguous will return `None` in such cases. |
51 |
| -For example, "a month later" of 2014-01-30 is not well-defined |
52 |
| -and consequently `Utc.ymd_opt(2014, 1, 30).unwrap().with_month(2)` returns `None`. |
| 74 | +This project is licensed under either of |
53 | 75 |
|
54 |
| -Non ISO week handling is not yet supported. |
55 |
| -For now you can use the [chrono_ext](https://crates.io/crates/chrono_ext) |
56 |
| -crate ([sources](https://github.com/bcourtine/chrono-ext/)). |
| 76 | +* [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) |
| 77 | +* [MIT License](https://opensource.org/licenses/MIT) |
57 | 78 |
|
58 |
| -Advanced time zone handling is not yet supported. |
59 |
| -For now you can try the [Chrono-tz](https://github.com/chronotope/chrono-tz/) crate instead. |
| 79 | +at your option. |
0 commit comments