All notable changes to the time project will be documented in this file.
The format is based on Keep a Changelog. This project adheres to Semantic Versioning.
- The amount of code generated by
time::serde::format_description!
is reduced if not all feature flags are active. cargo test --tests
works with any configuration of feature flags. This occurs by spawning a subprocess that passes--all-features
.cargo test --doc
works with most combinations of feature flags, including the default. The combination of these changes means that crater will now run ontime
.libc
andnum_threads
are only included as dependencies when needed. They were previously unconditionally included.
time::format_description::parse_owned
, which returns anOwnedFormatItem
. This avoids "lifetime hell", where all your structs now need a lifetime because a single field has one. Note that when possible, the borrowed format item (just calledFormatItem
) is still preferred, as it has significantly fewer allocations. The newOwnedFormatItem
is usable for both formatting and parsing, as you would expect.
- The parser for runtime format descriptions has been rewritten. A side effect of this is that some errors have slightly changed. No existing API has been altered, so this is not a breaking change. However, you may notice different errors, which are hopefully better! The parser for compile-time format descriptions has not yet been swapped out. If you notice any bugs, please file an issue.
- The minimum supported Rust version is now 1.60.0.
- The
serde-well-known
feature flag is deprecated. The necessary features for an item to be enabled are indicated in documentation. - Feature gates have been loosened for well-known formats.
-
const
s can now be provided as the format description fortime::serde::format_description!
. Theconst
must be of type&[FormatItem<'_>]
, which is what is returned by thetime::macros::format_description!
macro.const TIME_FORMAT_ALT: &[FormatItem<'_>] = time::macros::format_description!("[hour]:[minute]"); time::serde::format_description!(time_format_alt, Time, TIME_FORMAT_ALT);
- Some feature flags have been removed. None of these have ever been documented as flags, so any use
was unsupported. These flags are:
js-sys
quickcheck-dep
itoa
time-macros
- Better gating for
tm_gmtoff
extension. This should eliminate build failures on some untested platforms. Debug
output for types are now human-readable. While this should not be relied upon, it is currently the same as the output withDisplay
.- Eliminate overflows in the constructors for `Duration. When there is an overflow, the methods now panic. This was previously only the case in debug mode.
- Panic if
NaN
is passed toDuration::from_secs_f32
orDuration::from_secs_f64
.
- Fix error when deserializing data types from bytes. This affects formats such as JSON.
- Eliminate a panic in an edge case when converting
OffsetDateTime
to anotherUtcOffset
. This occurred due to an old assumption in code that was no longer the case.
- The minimum supported Rust version is now 1.59.0.
Duration::unsigned_abs
is nowconst fn
.- The const parameter for
time::format_description::well_known::Iso8601
now has a default. This meansIso8601
is the same asIso8601::DEFAULT
. - The
Parsed
struct has been reduced in size from 56 to 32 bytes (a 43% reduction).
- wasm builds other than those using
wasm-bindgen
work again.
js-sys
now supports obtaining the system's local UTC offset.
- Performance of many
Date
operations has improved when using thelarge-dates
feature. - While an internal change,
OffsetDateTime
now stores the value in the attachedUtcOffset
, not UTC. This leads to significant performance gains on nearly allOffsetDateTime
methods.
- Subtracting two
Time
s can no longer panic. This previously occurred in some situations where the result was invalid. - ISO 8601 parsing rounds the subseconds to avoid incorrectly truncating the value.
- [#479]: regression when parsing optional values with
serde
- [#481]:
Time
subtracted fromTime
can panic. This was caused by a bug that has always existed, in that an internal invariant was not upheld. Memory safety was not violated.
- Serde support for non-self-describing formats
Duration::unsigned_abs
, which returns astd::time::Duration
- ISO 8601 well-known format
Duration
can now be formatted with a.N
specifier, providing a shorter representation when usingDisplay
.- Parse
null
asNone
on serde structs
- Fix incorrect parsing of UTC offset in
Rfc3339
.
- The minimum supported Rust version is now 1.57.0.
- Performance for
Rfc2822
has been improved. - Debug assertions have been added in a few places. This should have no user facing impact, as it only serves to catch bugs and is disabled in release mode.
time::serde::format_description!
- This macro is similar to
time::format_description!
, but it generates a module that can be used in#[serde(with = "foo")]
. This makes it far easier to serialize/deserialize a custom format.
- This macro is similar to
Date::replace_year
Date::replace_month
Date::replace_day
Time::replace_hour
Time::replace_minute
Time::replace_second
Time::replace_millisecond
Time::replace_microsecond
Time::replace_nanosecond
PrimitiveDateTime::replace_year
PrimitiveDateTime::replace_month
PrimitiveDateTime::replace_day
PrimitiveDateTime::replace_hour
PrimitiveDateTime::replace_minute
PrimitiveDateTime::replace_second
PrimitiveDateTime::replace_millisecond
PrimitiveDateTime::replace_microsecond
PrimitiveDateTime::replace_nanosecond
OffsetDateTime::replace_year
OffsetDateTime::replace_month
OffsetDateTime::replace_day
OffsetDateTime::replace_hour
OffsetDateTime::replace_minute
OffsetDateTime::replace_second
OffsetDateTime::replace_millisecond
OffsetDateTime::replace_microsecond
OffsetDateTime::replace_nanosecond
Parsed::offset_minute_signed
Parsed::offset_second_signed
Parsed::set_offset_minute_signed
Parsed::set_offset_second_signed
Parsed::with_offset_minute_signed
Parsed::with_offset_second_signed
error::InvalidVariant
impl FromStr
forWeekday
impl FromStr
forMonth
impl Display for Duration
The following methods have been deprecated in favor of the new, signed equivalent methods. The pre-existing methods
Parsed::offset_minute
Parsed::offset_second
Parsed::set_offset_minute
Parsed::set_offset_second
Parsed::with_offset_minute
Parsed::with_offset_second
- Well-known formats that support leap seconds now return the
TryFromParsed::ComponentRange
error variant if the leap second could not occur at that given moment.
This release is broken and has been yanked.
Solaris and Illumos build again.
Date::saturating_add
Date::saturating_sub
PrimitiveDateTime::saturating_add
PrimitiveDateTime::saturating_sub
OffsetDateTime::saturating_add
OffsetDateTime::saturating_sub
PrimitiveDatetime::MIN
PrimitiveDatetime::MAX
Rfc2822
format description- Serde support for well-known formats
- This is placed behind the new
serde-well-known
feature flag.
- This is placed behind the new
- MacOS and FreeBSD are supported obtaining the local offset when single-threaded.
- Starting with this version, this is delegated to the
num_threads
crate.
- Starting with this version, this is delegated to the
- Leap seconds are now parsed as the final nanosecond of the preceding second.
- The minimum supported Rust version is now 1.53.0.
- Deserializers for human readable formats will fall back to the binary format if the human readable format fails to deserialize.
- Deserialization will no longer fail when given a non-borrowed string.
Date::checked_add
Date::checked_sub
PrimitiveDateTime::checked_add
PrimitiveDateTime::checked_sub
OffsetDateTime::checked_add
OffsetDateTime::checked_sub
- Attempts to obtain the local UTC offset will now succeed on Linux if the process is
single-threaded. This does not affect other Unix platforms. As a reminder, the relevant methods
are fallible and may return an
Err
value for any reason.
error::DifferentVariant
andError::DifferentVariant
impl From<Component> for FormatItem<'_>
impl TryFrom<FormatItem<'_>> for Component
impl<'a> From<&'a [FormatItem<'_>]> for FormatItem<'a>
impl<'a> TryFrom<FormatItem<'a>> for &[FormatItem<'a>]
impl PartialEq<Component> for FormatItem<'_>
impl PartialEq<FormatItem<'_>> for Component
impl PartialEq<&[FormatItem<'_>]> for FormatItem<'_>
impl PartialEq<FormatItem<'_>> for &[FormatItem<'_>]
impl TryFrom<Error> for error::TryFromParsed
impl TryFrom<Error> for error::Parse
impl TryFrom<Error> for error::ParseFromDescription
impl TryFrom<Error> for error::InvalidFormatDescription
impl TryFrom<Error> for error::IndeterminateOffset
impl TryFrom<Error> for error::Format
impl TryFrom<Error> for error::ConversionRange
impl TryFrom<Error> for error::ComponentRange
impl TryFrom<error::TryFromParsed> for error::ComponentRange
impl TryFrom<error::Parse> for error::TryFromParsed
impl TryFrom<error::Parse> for error::ParseFromDescription
impl TryFrom<error::Format> for std::io::Error
impl Sum for Duration
impl Sum<&Duration> for Duration
- A
const fn default()
has been added to all modifiers that arestruct
s. These methods exist to permit construction inconst
contexts and may be removed (without being considered a breaking change) onceimpl const Default
is stabilized. FormatItem::Optional
, which will consume the contained value if present but still succeed otherwise.FormatItem::First
, which will consume the first successful parse, ignoring any prior errors.
- Cross-building to Windows now succeeds.
- A parse error on a
UtcOffset
component now indicates the error comes from the offset. - Some arithmetic no longer panics in edge cases.
Parsed::parse_item
Parsed::parse_items
Parsed::parse_literal
- Builder methods for
Parsed
- The
format_description!
macro now supports thecase_sensitive
modifier.
The minimum supported version is now 1.51.0.
Instant
is now#[repr(transparent)]
- Constructing a
Date
from its ISO year, week, and weekday now returns the correct value in all circumstances. Previously, dates with an ISO year less than zero may have returned incorrect values. This affects both theDate::from_iso_week_date
method and thedate!
macro.
Month
now implementsTryFrom<u8>
From<Month>
is now implemented foru8
- The parser now accepts "5 PM" and similar as a valid time. Only the 12-hour clock hour and the AM/PM suffix may be present; any other components representing a time will cause an error (this exact behavior is not guaranteed).
- The
time!
macro accepts the "5 PM" syntax with the same restriction.
- Macros that have a time component (
time!
anddatetime!
) no longer accept "0:00 AM" and similar. This was previously erroneously accepted.
datetime!
macro, which allows the construction of a statically verifiedPrimitiveDateTime
orOffsetDateTime
.PrimitiveDateTime::replace_time
PrimitiveDateTime::replace_date
OffsetDateTime::replace_time
OffsetDateTime::replace_date
OffsetDateTime::replace_date_time
OffsetDateTime::replace_offset
#![no_alloc]
supportDate::to_iso_week_date
, replacingDate::iso_year_week
Date::MIN
Date::MAX
UtcOffset::from_hms
UtcOffset::from_whole_seconds
UtcOffset::as_hms
UtcOffset::whole_hours
UtcOffset::whole_minutes
UtcOffset::minutes_past_hour
UtcOffset::seconds_past_minute
UtcOffset::is_utc
UtcOffset::is_positive
UtcOffset::is_negative
OffsetDateTime::sunday_based_week
OffsetDateTime::monday_based_week
PrimitiveDateTime::to_calendar_date
PrimitiveDateTime::to_ordinal_date
PrimitiveDateTime::to_iso_week_date
PrimitiveDateTime::to_julian_day
OffsetDateTime::to_calendar_date
OffsetDateTime::to_ordinal_date
OffsetDateTime::to_iso_week_date
OffsetDateTime::to_julian_day
Time::as_hms
Time::as_hms_milli
Time::as_hms_micro
Time::as_hms_nano
PrimitiveDateTime::as_hms
PrimitiveDateTime::as_hms_milli
PrimitiveDateTime::as_hms_micro
PrimitiveDateTime::as_hms_nano
OffsetDateTime::to_hms
OffsetDateTime::to_hms_milli
OffsetDateTime::to_hms_micro
OffsetDateTime::to_hms_nano
Duration::saturating_add
Duration::saturating_sub
Duration::saturating_mul
util::days_in_year_month
Month
Instant::into_inner
impl AsRef<StdInstant>
andimpl Borrow<StdInstant>
forInstant
- Support for obtaining the local UTC offset on Unix-like systems has been re-added under a
user-provided flag. This functionality is not tested in any way and is not guaranteed to work.
Library authors are unable to enable this feature, as it must be passed via
RUSTFLAGS
. Further information is available in the documentation.
- The minimum supported Rust version is now 1.48.0. Per the policy in the README, this may be bumped within the 0.3 series without being a breaking change.
- rand has been updated to 0.8.
- quickcheck has been updated to 1.0.
- Macros are placed behind the
macros
feature flag. - Renamed
OffsetDatetime::timestamp
→OffsetDateTime::unix_timestamp
OffsetDatetime::timestamp_nanos
→OffsetDateTime::unix_timestamp_nanos
Date::try_from_ymd
→Date::from_calendar_date
Date::try_from_yo
→Date::from_ordinal_date
Date::try_from_iso_ywd
→Date::from_iso_week_date
Date::as_ymd
→Date::to_calendar_date
Date::as_yo
→Date::to_ordinal_date
Date::try_with_hms
→Date::with_hms
Date::try_with_hms_milli
→Date::with_hms_milli
Date::try_with_hms_micro
→Date::with_hms_micro
Date::try_with_hms_nano
→Date::with_hms_nano
Time::try_from_hms
→Time::from_hms
Time::try_from_hms_milli
→Time::from_hms_milli
Time::try_from_hms_micro
→Time::from_hms_micro
Time::try_from_hms_nano
→Time::from_hms_nano
UtcOffset::try_local_offset_at
→UtcOffset::local_offset_at
UtcOffset::as_seconds
→UtcOffset::whole_seconds
OffsetDateTime::try_now_local
→OffsetDateTime::now_local
Date::week
→Date::iso_week
PrimitiveDateTime::week
→PrimitiveDateTime::iso_week
OffsetDateTime::week
→OffsetDateTime::iso_week
Date::julian_day
→Date::to_julian_day
- All
Duration
unit values, as well as the minimum and maximum, are now associated constants. OffsetDateTime::unix_epoch()
→OffsetDateTime::UNIX_EPOCH
Time::midnight()
→Time::MIDNIGHT
- Now
const fn
(on at least newer compilers)Date::weekday
Date::next_day
Date::previous_day
PrimitiveDateTime::assume_offset
PrimitiveDateTime::weekday
Duration::checked_add
Duration::checked_sub
Duration::checked_mul
OffsetDateTime::from_unix_timestamp
OffsetDateTime::from_unix_timestamp_nanos
OffsetDateTime::date
OffsetDateTime::time
OffsetDateTime::year
OffsetDateTime::month
OffsetDateTime::day
OffsetDateTime::ordinal
OffsetDateTime::to_iso_week_date
OffsetDateTime::week
OffsetDateTime::weekday
OffsetDateTime::hour
OffsetDateTime::minute
OffsetDateTime::second
OffsetDateTime::millisecond
OffsetDateTime::microsecond
OffsetDateTime::nanosecond
OffsetDateTime::unix_timestamp
OffsetDateTime::unix_timestamp_nanos
- The following functions now return a
Result
:Date::from_julian_day
OffsetDateTime::from_unix_timestamp
OffsetDateTime::from_unix_timestamp_nanos
- The following functions now return an
Option
:Date::next_day
Date::previous_day
- The range of valid years has changed. By default, it is ±9999. When using the
large-dates
feature, this is increased to ±999,999. Enabling the feature has performance implications and introduces ambiguities when parsing. - The following are now gated under the
local-offset
feature:UtcOffset::local_offset_at
OffsetDateTime::now_local
Instant
is now guaranteed to be represented as a tuple struct containing astd::time::Instant
.- Macros are guaranteed to be evaluated at compile time.
Date::to_julian_day
now returns ani32
(wasi64
).Date::from_julian_day
now accepts ani32
(wasi64
).- Extension traits are only implemented for some types and are now sealed. As they are intended to be used with value literals, the breakage caused by this should be minimal.
- The new
Month
enum is used instead of numerical values where appropriate.
- v0.1 APIs, previously behind an enabled-by-default feature flag
PreciseTime
SteadyTime
precise_time_ns
precise_time_s
Instant::to
Duration::num_weeks
Duration::num_days
Duration::num_hours
Duration::num_minutes
Duration::num_seconds
Duration::num_milliseconds
Duration::num_microseconds
Duration::num_nanoseconds
Duration::span
Duration::from_std
Duration::to_std
- Panicking APIs, previously behind a non-default feature flag
Date::from_ymd
Date::from_yo
Date::from_iso_ywd
Date::with_hms
Date::with_hms_milli
Date::with_hms_micro
Date::with_hms_nano
Time::from_hms
Time::from_hms_milli
Time::from_hms_micro
Time::from_hms_nano
- APIs that assumed an offset of UTC, previously enabled unconditionally
Date::today
Time::now
PrimitiveDateTime::now
PrimitiveDateTime::unix_epoch
PrimitiveDateTime::from_unix_timestamp
PrimitiveDateTime::timestamp
OffsetDateTime::now
impl Sub<SystemTime> for PrimitiveDateTime
impl Sub<PrimitiveDateTime> for SystemTime
impl PartialEq<SystemTime> for PrimitiveDateTime
impl PartialEq<PrimitiveDateTime> for SystemTime
impl PartialOrd<SystemTime> for PrimitiveDateTime
impl PartialOrd<PrimitiveDateTime> for SystemTime
impl From<SystemTime> for PrimitiveDateTime
impl From<PrimitiveDateTime> for SystemTime
UtcOffset::local_offset_at
— assumed UTC if unable to determine local offsetOffsetDateTime::now_local
— assumed UTC if unable to determine local offset
- Other APIs deprecated during the course of 0.2, previously enabled unconditionally
Duration::sign
PrimitiveDateTime::using_offset
Sign
- Re-exports of APIs moved during the course of 0.2
days_in_year
is_leap_year
validate_format_string
weeks_in_year
ComponentRangeError
ConversionRangeError
IndeterminateOffsetError
ParseError
NumericalDuration
NumericalStdDuration
NumericalStdDurationShort
- All top-level macros
- Lazy formatting, which was unidiomatic as a failure would have returned
fmt::Error
, indicating an error unrelated to the time crate.Time::lazy_format
Date::lazy_format
UtcOffset::lazy_format
PrimitiveDateTime::lazy_format
OffsetDateTime::lazy_format
- Support for stdweb has been removed, as the crate is unmaintained.
- The
prelude
module has been removed in its entirety. Date::iso_year_week
in favor ofDate::to_iso_week_date
PrimitiveDateTime::iso_year_week
OffsetDateTime::iso_year_week
UtcOffset::east_hours
UtcOffset::west_hours
UtcOffset::hours
UtcOffset::east_minutes
UtcOffset::west_minutes
UtcOffset::minutes
UtcOffset::east_seconds
UtcOffset::west_seconds
UtcOffset::seconds
Date::month_day
PrimitiveDateTime::month_day
OffsetDateTime::month_day
Weekday::iso_weekday_number
(identical toWeekday::number_from_monday
)ext::NumericalStdDurationShort
- #316, where the build script was wrongly unable to determine the correct compiler version
- Dependencies have been bumped to the latest patch version, ensuring compatibility.
- Fix #309, which can cause panics in certain situations.
- The implementation of
OffsetDateTime::timestamp
,OffsetDateTime::unix_timestamp
,PrimitiveDatetime::timestamp
, andOffsetDateTime::unix_timestamp
have been corrected. This affects all negative timestamps with a nonzero subsecond value.
Due to #293, any method that requires knowledge of the local offset will now
fail on Linux. For try_
methods, this means returning an error. For others,
it means assuming UTC.
UtcOffset::timestamp
(moved toUtcOffset::unix_timestamp
)UtcOffset::timestamp_nanos
(moved toUtcOffset::unix_timestamp_nanos
)date
(moved tomacros::date
)time
(moved tomacros::time
)offset
(moved tomacros::offset
)OffsetDateTime::now_local
(assumes UTC if unable to be determined)UtcOffset::local_offset_at
(assumes UTC if unable to be determined)UtcOffset::current_local_offset
(assumes UTC if unable to be determined)
- Solaris & Illumos now successfully build.
Duration::new
could previously result in an inconsistent internal state. This led to some odd situations where aDuration
could be both positive and negative. This has been fixed such that the internal state maintains its invariants.
- Implementation details of some error types have been exposed. This means that data about a component being out of range can be directly obtained, while an invalid offset or conversion error is guaranteed to be a zero-sized type.
- The following functions are
const fn
on rustc ≥ 1.46:Date::try_from_iso_ywd
Date::iso_year_week
Date::week
Date::sunday_based_week
Date::monday_based_week
Date::try_with_hms
Date::try_with_hms_milli
Date::try_with_hms_micro
Date::try_with_hms_nano
PrimitiveDateTime::iso_year_week
PrimitiveDateTime::week
PrimitiveDateTime::sunday_based_week
PrimitiveDateTime::monday_based_week
util::weeks_in_year
OffsetDateTime::timestamp_nanos
OffsetDateTime::from_unix_timestamp_nanos
A bug with far-reaching consequences has been fixed. See #276 for complete details, but the gist is
that the constructing a Date
from a valid Julian day may result in an invalid value or even panic.
As a consequence of implementation details, this affects nearly all arithmetic with Date
s (and as
a result also PrimitiveDateTime
s and OffsetDateTime
s).
- Document how to construct an
OffsetDateTime
from a timestamp-nanosecond pair
- The build script now declares a dependency on the
COMPILING_UNDER_CARGO_WEB
environment variable. - Parsing the
%D
specifier no longer requires padding on the month. Previously,Err(InvalidMonth)
was incorrectly returned. - A
std::time::Duration
that is larger thantime::Duration::max_value()
now correctly returnsOrdering::Greater
when compared. - Multiplying and assigning an integer by
Sign::Zero
now sets the integer to be zero. This previously left the integer unmodified.
- The following functions are
const fn
on rustc ≥ 1.46:Date::try_from_ymd
Date::try_from_yo
Time::try_from_hms
Time::try_from_hms_milli
Time::try_from_hms_micro
Time::try_from_hms_nano
- An
error
module has been created where all existing error types are contained. TheError
suffix has been dropped from these types. - An
ext
module has been created where extension traits are contained. - A
util
module has been created where utility functions are contained. error::ComponentRange
now implementsCopy
.
For back-compatibility, all items that were moved to newly-contained modules have been re-exported
from their previous locations (and in the case of the error
module, with their previous name).
Parsing format::Rfc3339
now correctly handles the UTC offset (#274).
The following functions are const fn
on rustc ≥ 1.46:
Date::year
Date::month
Date::day
Date::month_day
Date::ordinal
Date::as_ymd
Date::as_yo
Date::julian_day
Duration::checked_div
PrimitiveDateTime::year
PrimitiveDateTime::month
PrimitiveDateTime::day
PrimitiveDateTime::month_day
PrimitiveDateTime::ordinal
Weekday::previous
Weekday::next
size_of::<Date>()
has been reduced from 8 to 4. As a consequence,size_of::<PrimitiveDatetime>()
went from 16 to 12 andsize_of::<OffsetDateTime>()
from 20 to 16. This change also results in a performance improvement of approximately 30% on theDate::year
andDate::ordinal
methods.cfg-if
has been removed as a dependency.
cfg
flags passed to rustc will no longer collide with other crates (at least unless they're doing something very stupid).- The crate will successfully compile with any combination of feature flags. Previously, some combinations would fail.
OffsetDateTime
s can now be represented as Unix timestamps with serde. To do this, you can use the
time::serde::timestamp
and time::serde::timestamp::option
modules.
cargo-web
support works, and is now explicitly checked in CI. A previous change was made that made
a method call ambiguous.
Adding/subtracting a core::time::Duration
now correctly takes subsecond values into account. This
also affects PrimitiveDateTime
and OffsetDateTime
.
Panicking APIs are re-exposed.
Subtracting Instant
s can correctly result in a negative duration, rather than resulting in the
absolute value of it.
OffsetDateTime::now_utc
OffsetDateTime::now
due to the offset not being clear from the method name alone.
Date
s are now uniformly random when using the rand
crate. Previously, both the year and day
within the year were uniform, but this meant that any given day in a leap year was slightly less
likely to be chosen than a day in a non-leap year.
- MSRV is lowered to 1.32.0.
- Support for formatting and parsing
OffsetDateTime
s as RFC3339. - Lazy formatting. To avoid exposing implementation details, we're just returning
impl Display
, rather than a concrete type. - Add support for Illumos.
- Deprecated APIs from time v0.1 are public again. They were previously hidden by accident in 0.2.9.
cfg-if
now has a mandatory minimum of 0.1.10, rather than just 0.1. This is because compilation
fails when using 0.1.9.
cargo_web
support has been added for getting a local offset. A general catch-all defaulting to UTC has also been added.Error::source
has been implemented for the wrappertime::Error
.UtcOffset::try_local_offset
,UtcOffset::try_current_local_offset
,OffsetDateTime::try_now_local()
provide fallible alternatives when the default of UTC is not desired. To facilitate this change,IndeterminateOffsetError
has been added.- Support for parsing and formatting subsecond nanoseconds.
#[non_exhaustive]
is simulated on compilers prior to 1.40.0.
Display
has been implemented forDate
,OffsetDateTime
,PrimitiveDateTime
,Time
,UtcOffset
, andWeekday
.Hash
is now derived forDuration
.SystemTime
can be converted to and fromOffsetDateTime
. The following trait implementations have been made for interoperability:impl Sub<SystemTime> for OffsetDateTime
impl Sub<OffsetDateTime> for SystemTime
impl PartialEq<SystemTime> for OffsetDateTime
impl PartialEq<OffsetDateTime> for SystemTime
impl PartialOrd<SystemTime> for OffsetDateTime
impl PartialOrd<OffsetDateTime> for SystemTime
impl From<SystemTime> for OffsetDateTime
impl From<OffsetDateTime> for SystemTime
- All structs now
impl Duration<T> for Standard
, allowing usage with therand
crate. This is gated behind therand
feature flag. - Documentation can now be built on stable. Some annotations will be missing if you do this.
NumericalDuration
has been implemented forf32
andf64
.NumericalStdDuration
andNumericalStdDurationShort
have been implemented forf64
only.UtcOffset::local_offset_at(OffsetDateTime)
, which will obtain the system's local offset at the provided moment in time.OffsetDateTime::now_local()
is equivalent to callingOffsetDateTime::now().to_offset(UtcOffset::local_offset_at(OffsetDateTime::now()))
(but more efficient).UtcOffset::current_local_offset()
will return the equivalent ofOffsetDateTime::now_local().offset()
.
- All formatting and parsing methods now accept
impl AsRef<str>
as parameters, rather than just&str
.time::validate_format_string
does this as well. - The requirement of a
Date
being between the years -100,000 and +100,000 (inclusive) is now strictly enforced. - Overflow checks for
Duration
are now enabled by default. This behavior is the identical to what the standard library does. - The
time
,date
, andoffset
macros have been added to the prelude.
-
Sign
has been deprecated in its entirety, along withDuration::sign
.To obtain the sign of a
Duration
, you can use theDuration::is_positive
,Duration::is_negative
, andDuration::is_zero
methods. -
A number of functions and trait implementations that implicitly assumed a timezone (generally UTC) have been deprecated. These are:
Date::today
Time::now
PrimitiveDateTime::now
PrimitiveDateTime::unix_epoch
PrimitiveDateTime::from_unix_timestamp
PrimitiveDateTime::timestamp
impl Sub<SystemTime> for PrimitiveDateTime
impl Sub<PrimitiveDateTime> for SystemTime
impl PartialEq<SystemTime> for PrimitiveDateTime
impl PartialEq<PrimitiveDateTime> for SystemTime>
impl PartialOrd<SystemTime> for PrimitiveDateTime
impl PartialOrd<PrimitiveDateTime> for SystemTime>
impl From<SystemTime> for PrimitiveDateTime
impl From<PrimitiveDateTime> for SystemTime
- Avoid panics when parsing an empty string (#215).
- The nanoseconds component of a
Duration
is now always in range. Previously, it was possible (via addition and/or subtraction) to obtain a value that was not internally consistent. Time::parse
erroneously returned anInvalidMinute
error when it was actually the second that was invalid.Date::parse("0000-01-01", "%Y-%m-%d")
incorrectly returned anErr
(#221).
Prior to v0.2.7, changes were listed in GitHub releases.