v0.4.0
Original annoucement: https://users.rust-lang.org/t/chrono-0-4-0-is-out/11466.
The new version of Chrono, the date and time library for Rust, has been released.
This version fixes the dependency issues raised in 0.3.1 (in lieu of this release, 0.3.1 is now yanked as well) while moving towards the more idiomatic API convention. This version was developed in relatively heavy time constraints, but I have managed to include several goodies:
DateTimetypes can now be serialized to, or deserialized from the integral UNIX timestamp.DateTimetypes andstd::time::SystemTimecan be freely converted back and forth viaFrom.IsoWeektype has been introduced.- The documentation has been streamlined by removing intermediate implementation modules and accounting for several minor but essential suggestions.
This was originally planned as a minor release but was pushed to a major release due to the compatibility concern raised.
Added
-
IsoWeekhas been added for the ISO week without time zone. -
The
+=and-=operators againsttime::Durationare now supported forNaiveDate,NaiveTimeandNaiveDateTime. (#99)(Note that this does not invalidate the eventual deprecation of
time::Duration.) -
SystemTimeandDateTime<Tz>types can be now converted to each other viaFrom. Due to the obvious lack of time zone information inSystemTime, the forward direction is limited toDateTime<Utc>andDateTime<Local>only.
Changed
-
Intermediate implementation modules have been flattened (#161), and
UTChas been renamed toUtcin accordance with the current convention (#148).The full list of changes is as follows:
Before After chrono::date::Datechrono::Datechrono::date::MINchrono::MIN_DATEchrono::date::MAXchrono::MAX_DATEchrono::datetime::DateTimechrono::DateTimechrono::naive::time::NaiveTimechrono::naive::NaiveTimechrono::naive::date::NaiveDatechrono::naive::NaiveDatechrono::naive::date::MINchrono::naive::MIN_DATEchrono::naive::date::MAXchrono::naive::MAX_DATEchrono::naive::datetime::NaiveDateTimechrono::naive::NaiveDateTimechrono::offset::utc::UTCchrono::offset::Utcchrono::offset::fixed::FixedOffsetchrono::offset::FixedOffsetchrono::offset::local::Localchrono::offset::Localchrono::format::parsed::Parsedchrono::format::ParsedWith an exception of
Utc, this change does not affect any direct usage ofchrono::*orchrono::prelude::*types. -
Datelike::isoweekdateis replaced byDatelike::iso_weekwhich only returns the ISO week.The original method used to return a tuple of year number, week number and day of the week, but this duplicated the
Datelike::weekdaymethod and it had been hard to deal with the raw year and week number for the ISO week date. This change isolates any logic and API for the week date into a separate type. -
NaiveDateTimeandDateTimecan now be deserialized from an integral UNIX timestamp. (#125)This turns out to be very common input for web-related usages. The existing string representation is still supported as well.
-
chrono::serdeandchrono::naive::serdemodules have been added for the serialization utilities. (#125)Currently they contain the
ts_secondsmodules that can be used to serializeNaiveDateTimeandDateTimevalues into an integral UNIX timestamp. This can be combined with Serde's[de]serialize_withattributes to fully support the (de)serialization to/from the timestamp.For rustc-serialize, there are separate
chrono::TsSecondsandchrono::naive::TsSecondstypes that are newtype wrappers implementing different (de)serialization logics. This is a suboptimal API, however, and it is strongly recommended to migrate to Serde.
Fixed
-
The major version was made to fix the broken Serde dependency issues. (#146, #156, #158, #159)
The original intention to technically break the dependency was to facilitate the use of Serde 1.0 at the expense of temporary breakage. Whether this was appropriate or not is quite debatable, but it became clear that there are several high-profile crates requiring Serde 0.9 and it is not feasible to force them to use Serde 1.0 anyway.
To the end, the new major release was made with some known lower-priority breaking changes. 0.3.1 is now yanked and any remaining 0.3 users can safely roll back to 0.3.0.