This documents notable changes to Chrono up to and including version 0.4.19. For later releases, please review the release notes on GitHub.
- Correct build on solaris/illumos
- Restore support for x86_64-fortanix-unknown-sgx
- Fix a name resolution error in wasm-bindgen code introduced by removing the dependency on time v0.1
-
Add %Z specifier to the
FromStr
, similar to the glibc strptime (does not set the offset from the timezone name) -
Drop the dependency on time v0.1, which is deprecated, unless the
oldtime
feature is active. This feature is active by default in v0.4.16 for backwards compatibility, but will likely be removed in v0.5. Code that importstime::Duration
should be switched to importchrono::Duration
instead to avoid breakage.
- Correct usage of vec in specific feature combinations (@quodlibetor)
- Add day and week iterators for
NaiveDate
(@gnzlbg & @robyoung) - Add a
Month
enum (@hhamana) - Add
locales
. All format functions can now use locales, see the documentation for theunstable-locales
feature. - Fix
Local.from_local_datetime
method for wasm
- Added MIN and MAX values for
NaiveTime
,NaiveDateTime
andDateTime<Utc>
.
- Add
DurationRound
trait that allows rounding and truncating byDuration
(@robyoung)
- Code improvements to impl
From
forjs_sys
in wasm to reuse code (@schrieveslaach)
Duration::abs
to ensure that a duration is just a magnitude (#418 @abreis).
- impl
From
forjs_sys
in wasm (#424 @schrieveslaach) - Bump required version of
time
for redox support.
- serde modules do a better job with
Option
types (#417 @mwkroening and #429 @fx-kirin) - Use js runtime when using wasmbind to get the local offset (#412 @quodlibetor)
- Migrate to github actions from travis-ci, make the overall CI experience more comprehensible, significantly faster and more correct (#439 @quodlibetor)
- Support a space or
T
inFromStr
forDateTime<Tz>
, meaning that e.g.dt.to_string().parse::<DateTime<Utc>>()
now correctly works on round-trip. (@quodlibetor in #378) - Support "negative UTC" in
parse_from_rfc2822
(@quodlibetor #368 reported in #102) - Support comparisons of DateTimes with different timezones (@dlalic in #375)
- Many documentation improvements
- Don't use wasmbind on wasi (@coolreader18 #365)
- Avoid deprecation warnings for
Error::description
(@AnderEnder and @quodlibetor #376)
- Use Criterion for benchmarks (@quodlibetor)
- Putting some functionality behind an
alloc
feature to improve no-std support (in #341) means that if you were relying on chrono withno-default-features
and using any of the functions that require alloc support (i.e. any of the string-generating functions liketo_rfc3339
) you will need to add thealloc
feature in your Cargo.toml.
DateTime::parse_from_str
is more than 2x faster in some cases. (@michalsrb #358)- Significant improvements to no-std and alloc support (This should also make many format/serialization operations induce zero unnecessary allocations) (@CryZe #341)
- Functions that were accepting
Iterator
ofItem
s (for exampleformat_with_items
) now acceptIterator
ofBorrow<Item>
, so one can use values or references. (@michalsrb #358) - Add built-in support for structs with nested
Option<Datetime>
etc fields (@manifest #302)
- Use markdown footnotes on the
strftime
docs page (@qudlibetor #359) - Migrate from
try!
->?
(question mark) because it is now emitting deprecation warnings and has been stable since rustc 1.13.0 - Deny dead code
- Make Datetime arithmetic adjust their offsets after discovering their new timestamps (@quodlibetor #337)
- Put wasm-bindgen related code and dependencies behind a
wasmbind
feature gate. (@quodlibetor #335)
- Add '0' to single-digit days in rfc2822 date format (@wyhaya #323)
- Correctly pad DelayedFormat (@SamokhinIlya #320)
- Support
wasm-unknown-unknown
via wasm-bindgen (in addition to emscripten/wasm-unknown-emscripten
). (finished by @evq in #331, initial work by @jjpe #287)
- Disable libc default features so that CI continues to work on rust 1.13
- Fix panic on negative inputs to timestamp_millis (@cmars #292)
- Make
LocalResult
Copy/Eq/Hash
- Add
std::convert::From
conversions between the different timezone formats (@mqudsi #271) - Add
timestamp_nanos
methods (@jean-airoldie #308) - Documentation improvements
- Doc improvements -- improve README CI verification, external links
- winapi upgrade to 0.3
- Added
NaiveDate::from_weekday_of_month{,_opt}
for getting eg. the 2nd Friday of March 2017.
- Added several more serde deserialization helpers (@novacrazy #258)
- Enabled all features on the playground (@davidtwco #267)
- Derive
Hash
onFixedOffset
(@LuoZijun #254) - Improved docs (@storyfeet #261, @quodlibetor #252)
- Added support for parsing nanoseconds without the leading dot (@emschwartz #251)
- Added methods to DateTime/NaiveDateTime to present the stored value as a number of nanoseconds since the UNIX epoch (@harkonenbade #247)
- Added a serde serialise/deserialise module for nanosecond timestamps. (@harkonenbade #247)
- Added "Permissive" timezone parsing which allows a numeric timezone to be specified without minutes. (@quodlibetor #242)
- More strongly deprecate RustcSerialize: remove it from documentation unless the feature is enabled, issue a deprecation warning if the rustc-serialize feature is enabled (@quodlibetor #174)
- Move all uses of the system clock behind a
clock
feature, for use in environments where we don't have access to the current time. (@jethrogb #236) - Implement subtraction of two
Date
s,Time
s, orDateTime
s, returning aDuration
(@tobz1000 #237)
- Allow parsing timestamps with subsecond precision (@jonasbb)
- RFC2822 allows times to not include the second (@upsuper)
- New
timestamp_millis
method onDateTime
andNaiveDateTime
that returns number of milliseconds since the epoch. (@quodlibetor) - Support exact decimal width on subsecond display for RFC3339 via a new
to_rfc3339_opts
method onDateTime
(@dekellum) - Use no_std-compatible num dependencies (@cuviper)
- Add
SubsecRound
trait that allows rounding to the nearest second (@dekellum)
- Docs! (@alatiera @kosta @quodlibetor @kennytm)
- Run clippy and various fixes (@quodlibetor)
This was originally planned as a minor release but was pushed to a major release due to the compatibility concern raised.
-
IsoWeek
has been added for the ISO week without time zone. -
The
+=
and-=
operators againsttime::Duration
are now supported forNaiveDate
,NaiveTime
andNaiveDateTime
. (#99)(Note that this does not invalidate the eventual deprecation of
time::Duration
.) -
SystemTime
andDateTime<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.
-
Intermediate implementation modules have been flattened (#161), and
UTC
has been renamed toUtc
in accordance with the current convention (#148).The full list of changes is as follows:
Before After chrono::date::Date
chrono::Date
chrono::date::MIN
chrono::MIN_DATE
chrono::date::MAX
chrono::MAX_DATE
chrono::datetime::DateTime
chrono::DateTime
chrono::naive::time::NaiveTime
chrono::naive::NaiveTime
chrono::naive::date::NaiveDate
chrono::naive::NaiveDate
chrono::naive::date::MIN
chrono::naive::MIN_DATE
chrono::naive::date::MAX
chrono::naive::MAX_DATE
chrono::naive::datetime::NaiveDateTime
chrono::naive::NaiveDateTime
chrono::offset::utc::UTC
chrono::offset::Utc
chrono::offset::fixed::FixedOffset
chrono::offset::FixedOffset
chrono::offset::local::Local
chrono::offset::Local
chrono::format::parsed::Parsed
chrono::format::Parsed
With an exception of
Utc
, this change does not affect any direct usage ofchrono::*
orchrono::prelude::*
types. -
Datelike::isoweekdate
is replaced byDatelike::iso_week
which 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::weekday
method 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. -
NaiveDateTime
andDateTime
can 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::serde
andchrono::naive::serde
modules have been added for the serialization utilities. (#125)Currently they contain the
ts_seconds
modules that can be used to serializeNaiveDateTime
andDateTime
values into an integral UNIX timestamp. This can be combined with Serde's[de]serialize_with
attributes to fully support the (de)serialization to/from the timestamp.For rustc-serialize, there are separate
chrono::TsSeconds
andchrono::naive::TsSeconds
types that are newtype wrappers implementing different (de)serialization logics. This is a suboptimal API, however, and it is strongly recommended to migrate to Serde.
-
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.
-
Various documentation fixes and goodies. (#92, #131, #136)
-
Weekday
now implementsFromStr
,Serialize
andDeserialize
. (#113)The syntax is identical to
%A
, i.e. either the shortest or the longest form of English names.
-
Serde 1.0 is now supported. (#142)
This is technically a breaking change because Serde 0.9 and 1.0 are not compatible, but this time we decided not to issue a minor version because we have already seen Serde 0.8 and 0.9 compatibility problems even after 0.3.0 and a new minor version turned out to be not very helpful for this kind of issues.
- Fixed a bug that the leap second can be mapped wrongly in the local time zone. Only occurs when the local time zone is behind UTC. (#130)
The project has moved to the Chronotope organization.
-
chrono::prelude
module has been added. All other glob imports are now discouraged. -
FixedOffset
can be added to or subtracted from any timelike types.FixedOffset::local_minus_utc
andFixedOffset::utc_minus_local
methods have been added. Note that the oldOffset::local_minus_utc
method is gone; see below.
-
Serde support for non-self-describing formats like Bincode is added. (#89)
-
Added
Item::Owned{Literal,Space}
variants for owned formatting items. (#76) -
Formatting items and the
Parsed
type have been slightly adjusted so that they can be internally extended without breaking any compatibility. -
Weekday
is nowHash
able. (#109) -
ParseError
now implementsEq
as well asPartialEq
. (#114) -
More documentation improvements. (#101, #108, #112)
-
Chrono now only supports Rust 1.13.0 or later (previously: Rust 1.8.0 or later).
-
Serde 0.9 is now supported. Due to the API difference, support for 0.8 or older is discontinued. (#122)
-
Rustc-serialize implementations are now on par with corresponding Serde implementations. They both standardize on the
std::fmt::Debug
textual output.This is a silent breaking change (hopefully the last though). You should be prepared for the format change if you depended on rustc-serialize.
-
Offset::local_minus_utc
is nowOffset::fix
, and returnsFixedOffset
instead of a duration.This makes every time zone operation operate within a bias less than one day, and vastly simplifies many logics.
-
chrono::format::format
now receivesFixedOffset
instead oftime::Duration
. -
The following methods and implementations have been renamed and older names have been removed. The older names will be reused for the same methods with
std::time::Duration
in the future.-
checked_*
→checked_*_signed
inDate
,DateTime
,NaiveDate
andNaiveDateTime
types -
overflowing_*
→overflowing_*_signed
in theNaiveTime
type -
All subtraction implementations between two time instants have been moved to
signed_duration_since
, following the naming instd::time
.
-
- Fixed a panic when the
Local
offset receives a leap second. (#123)
-
Rustc-serialize support for
Date<Tz>
types and all offset types has been dropped.These implementations were automatically derived and never had been in a good shape. Moreover there are no corresponding Serde implementations, limiting their usefulness. In the future they may be revived with more complete implementations.
-
The following method aliases deprecated in the 0.2 branch have been removed.
DateTime::num_seconds_from_unix_epoch
(→DateTime::timestamp
)NaiveDateTime::from_num_seconds_from_unix_epoch
(→NaiveDateTime::from_timestamp
)NaiveDateTime::from_num_seconds_from_unix_epoch_opt
(→NaiveDateTime::from_timestamp_opt
)NaiveDateTime::num_seconds_unix_epoch
(→NaiveDateTime::timestamp
)
-
Formatting items are no longer
Copy
, except forchrono::format::Pad
. -
chrono::offset::add_with_leapsecond
has been removed. Use a direct addition withFixedOffset
instead.
This is the last version officially supports Rust 1.12.0 or older.
(0.2.24 was accidentally uploaded without a proper check for warnings in the default state, and replaced by 0.2.25 very shortly. Duh.)
- Serde 0.8 is now supported. 0.7 also remains supported. (#86)
- The deserialization implementation for rustc-serialize now properly verifies the input. All serialization codes are also now thoroughly tested. (#42)
-
The documentation was greatly improved for several types, and tons of cross-references have been added. (#77, #78, #80, #82)
-
DateTime::timestamp_subsec_{millis,micros,nanos}
methods have been added. (#81)
-
When the system time records a leap second, the nanosecond component was mistakenly reset to zero. (#84)
-
Local
offset misbehaves in Windows for August and later, due to the long-standing libtime bug (dates back to mid-2015). Workaround has been implemented. (#85)
%.6f
and%.9f
used to print only three digits when the nanosecond part is zero. (#71)- The documentation for
%+
has been updated to reflect the current status. (#71)
Fixed::LongWeekdayName
was unable to recognize"sunday"
(whoops). (#66)
serde
dependency has been updated to 0.7. (#63, #64)
- The documentation for
Date
is made clear about its ambiguity and guarantees.
DateTime::date
had been wrong when the local date and the UTC date is in disagreement. (#61)
- Chrono no longer pulls a superfluous
rand
dependency. (#57)
- Naive date and time types and
DateTime
now have aserde
support. They serialize as an ISO 8601 / RFC 3339 string just likeDebug
. (#51)
- Added
%.3f
,%.6f
and%.9f
specifier for formatting fractional seconds up to 3, 6 or 9 decimal digits. This is a natural extension to the existing%f
. Note that this is (not yet) generic, no other value of precision is supported. (#45)
- Forbade unsized types from implementing
Datelike
andTimelike
. This does not make a big harm as any type implementing them should be already sized to be practical, but this change still can break highly generic codes. (#46)
- Fixed a broken link in the
README.md
. (#41)
-
Padding modifiers
%_?
,%-?
and%0?
are implemented. They are glibc extensions which seem to be reasonably widespread (e.g. Ruby). -
Added
%:z
specifier and corresponding formatting items which is essentially the same as%z
but with a colon. -
Added a new specifier
%.f
which precision adapts from the input. This was added as a response to the UX problems in the original nanosecond specifier%f
.
-
Numeric::Timestamp
specifier (%s
) was ignoring the time zone offset when provided. -
Improved the documentation and associated tests for
strftime
.
NaiveDateTime +/- Duration
orNaiveTime +/- Duration
could have gone wrong when theDuration
to be added is negative and has a fractional second part. This was caused by an underflow in the conversion fromDuration
to the parts; the lack of tests for this case allowed a bug. (#37)
- The optional dependency on
rustc_serialize
and relevantRustc{En,De}codable
implementations for supported types has been added. This is enabled by therustc-serialize
Cargo feature. (#34)
chrono::Duration
reexport is changed to that of crates.iotime
crate. This enables Rust 1.0 beta compatibility.
- Clarified the meaning of
Date<Tz>
and fixed unwanted conversion problem that only occurs with positive UTC offsets. (#27)
DateTime<Tz>
andDate<Tz>
is nowCopy
/Send
whenTz::Offset
isCopy
/Send
. The implementations for them were mistakenly omitted. (#25)
Local::from_utc_datetime
didn't set a correct offset. (#26)
DelayedFormat
no longer conveys a redundant lifetime.
-
Offset
is split intoTimeZone
(constructor) andOffset
(storage) types. You would normally see only the former, as the latter is mostly an implementation detail. Most importantly,Local
now can be used to directly construct timezone-aware values.Some types (currently,
UTC
andFixedOffset
) are bothTimeZone
andOffset
, but others aren't (e.g.Local
is not what is being stored to eachDateTime
values). -
LocalResult::map
convenience method has been added. -
TimeZone
now allows a construction ofDateTime
values from UNIX timestamp, viatimestamp
andtimestamp_opt
methods. -
TimeZone
now also has a method for parsingDateTime
, namelydatetime_from_str
. -
The following methods have been added to all date and time types:
checked_add
checked_sub
format_with_items
-
The following methods have been added to all timezone-aware types:
timezone
with_timezone
naive_utc
naive_local
-
parse_from_str
method has been added to all naive types andDateTime<FixedOffset>
. -
All naive types and instances of
DateTime
with time zonesUTC
,Local
andFixedOffset
implement theFromStr
trait. They parse whatstd::fmt::Debug
would print. -
chrono::format
has been greatly rewritten.-
The formatting syntax parser is modular now, available at
chrono::format::strftime
. -
The parser and resolution algorithm is also modular, the former is available at
chrono::format::parse
while the latter is available atchrono::format::parsed
. -
Explicit support for RFC 2822 and 3339 syntaxes is landed.
-
There is a minor formatting difference with atypical values, e.g. for years not between 1 BCE and 9999 CE.
-
-
Most uses of
Offset
are converted toTimeZone
. In fact, all user-facing code is expected to beOffset
-free. -
[Naive]DateTime::*num_seconds_from_unix_epoch*
methods have been renamed to simplytimestamp
orfrom_timestamp*
. The original names have been deprecated.
-
Time
has been removed. This also prompts a related set of methods inTimeZone
.This is in principle possible, but in practice has seen a little use because it can only be meaningfully constructed via an existing
DateTime
value. This made many operations toTime
unintuitive or ambiguous, so we simply let it go.In the case that
Time
is really required, one can use a simplerNaiveTime
.NaiveTime
andNaiveDate
can be freely combined and split, andTimeZone::from_{local,utc}_datetime
can be used to convert from/to the local time. -
with_offset
method has been removed. Usewith_timezone
method instead. (This is not deprecated since it is an integral part of offset reform.)
- Added a missing
std::fmt::String
impl forLocal
.
- Most types now implement both
std::fmt::Show
andstd::fmt::String
, with the former used for the stricter output and the latter used for more casual output.
Offset::name
has been replaced by astd::fmt::String
implementation toOffset
.
Duration + T
no longer works due to the updated impl reachability rules. UseT + Duration
as a workaround.
- Fixed a bug that
Date::and_*
methods with an offset that can change the date are off by one day.
-
{Date,Time,DateTime}::with_offset
methods have been added. -
LocalResult
now implements a common set of traits. -
LocalResult::and_*
methods have been added. They are useful for safely chainingLocalResult<Date<Off>>
methods to makeLocalResult<DateTime<Off>>
.
-
Offset::name
now returnsSendStr
. -
{Date,Time} - Duration
overloadings are now allowed.
Duration + Date
overloading is now allowed.
- Chrono no longer needs
num
dependency.
The initial version that was available to crates.io
.