time-macros
Procedural macros for the time crate. This crate is an implementation detail and should not be relied upon directly.
0.2.32
638M downloads/mo
#142 most downloaded on crates.io
time-rs/time
What this package is like to depend on
Last release 1 months ago
20 Jul 2026
Release timing varies
gaps range from 8 days to 8 months
Some releases are documented
notes for 20 of 34 stable releases
2 versions withdrawn
withdrawn after publishing
7 years old
38 releases · first in 2019
10 releases in the last 12 months
see the full history below
Release timeline
38 releases · Dec 2019 to Jul 2026Releases
latest 38-
0.2.3220 Jul 2026Nothing published for this version
-
0.2.3130 Jun 2026Nothing published for this version
-
0.2.3022 Jun 2026Nothing published for this version
-
0.2.2913 Jun 2026Nothing published for this version
-
0.2.2812 Jun 2026 withdrawnNothing published for this version
-
0.2.2705 Feb 2026Nothing published for this version
-
0.2.2624 Jan 2026Release notes
Open source →Fixed
- #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.
-
0.2.2513 Jan 2026 -
0.2.2402 Sep 2025Release notes
Open source →Fixed
- The implementation of
OffsetDateTime::timestamp,OffsetDateTime::unix_timestamp,PrimitiveDatetime::timestamp, andOffsetDateTime::unix_timestamphave been corrected. This affects all negative timestamps with a nonzero subsecond value.
- The implementation of
-
0.2.2331 Aug 2025Release notes
Open source →Compatibility notes
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.Deprecated
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)
-
0.2.2223 Mar 2025Release notes
Open source →Fixed
- Solaris & Illumos now successfully build.
Duration::newcould previously result in an inconsistent internal state. This led to some odd situations where aDurationcould be both positive and negative. This has been fixed such that the internal state maintains its invariants.
-
0.2.2118 Mar 2025Release notes
Open source →Changed
- 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 fnon rustc ≥ 1.46:Date::try_from_iso_ywdDate::iso_year_weekDate::weekDate::sunday_based_weekDate::monday_based_weekDate::try_with_hmsDate::try_with_hms_milliDate::try_with_hms_microDate::try_with_hms_nanoPrimitiveDateTime::iso_year_weekPrimitiveDateTime::weekPrimitiveDateTime::sunday_based_weekPrimitiveDateTime::monday_based_weekutil::weeks_in_year
-
0.2.2005 Mar 2025Release notes
Open source →Added
OffsetDateTime::timestamp_nanosOffsetDateTime::from_unix_timestamp_nanos
Fixed
A bug with far-reaching consequences has been fixed. See #276 for complete details, but the gist is that the constructing a
Datefrom a valid Julian day may result in an invalid value or even panic. As a consequence of implementation details, this affects nearly all arithmetic withDates (and as a result alsoPrimitiveDateTimes andOffsetDateTimes).Improvements
- Document how to construct an
OffsetDateTimefrom a timestamp-nanosecond pair
-
0.2.1903 Dec 2024Release notes
Open source →Fixed
- The build script now declares a dependency on the
COMPILING_UNDER_CARGO_WEBenvironment variable. - Parsing the
%Dspecifier no longer requires padding on the month. Previously,Err(InvalidMonth)was incorrectly returned. - A
std::time::Durationthat is larger thantime::Duration::max_value()now correctly returnsOrdering::Greaterwhen compared. - Multiplying and assigning an integer by
Sign::Zeronow sets the integer to be zero. This previously left the integer unmodified.
- The build script now declares a dependency on the
-
0.2.1810 Apr 2024Release notes
Open source →Changed
- The following functions are
const fnon rustc ≥ 1.46:Date::try_from_ymdDate::try_from_yoTime::try_from_hmsTime::try_from_hms_milliTime::try_from_hms_microTime::try_from_hms_nano
- An
errormodule has been created where all existing error types are contained. TheErrorsuffix has been dropped from these types. - An
extmodule has been created where extension traits are contained. - A
utilmodule has been created where utility functions are contained. error::ComponentRangenow 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
errormodule, with their previous name).Fixes
Parsing
format::Rfc3339now correctly handles the UTC offset (#274). - The following functions are
-
0.2.1701 Feb 2024Release notes
Open source →Changed
The following functions are
const fnon rustc ≥ 1.46:Date::yearDate::monthDate::dayDate::month_dayDate::ordinalDate::as_ymdDate::as_yoDate::julian_dayDuration::checked_divPrimitiveDateTime::yearPrimitiveDateTime::monthPrimitiveDateTime::dayPrimitiveDateTime::month_dayPrimitiveDateTime::ordinalWeekday::previousWeekday::next
Improvements
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::yearandDate::ordinalmethods.cfg-ifhas been removed as a dependency.
Fixed
cfgflags 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.
-
0.2.1619 Dec 2023Release notes
Open source →Added
OffsetDateTimes can now be represented as Unix timestamps with serde. To do this, you can use thetime::serde::timestampandtime::serde::timestamp::optionmodules. -
0.2.1524 Sep 2023Release notes
Open source →Fixed
cargo-websupport works, and is now explicitly checked in CI. A previous change was made that made a method call ambiguous. -
0.2.1427 Aug 2023Release notes
Open source →Fixed
Adding/subtracting a
core::time::Durationnow correctly takes subsecond values into account. This also affectsPrimitiveDateTimeandOffsetDateTime. -
0.2.1322 Aug 2023 -
0.2.1218 Aug 2023Release notes
Open source →Fixed
Subtracting
Instants can correctly result in a negative duration, rather than resulting in the absolute value of it. -
0.2.1130 Jul 2023Release notes
Open source →Added
OffsetDateTime::now_utc
Deprecated
OffsetDateTime::nowdue to the offset not being clear from the method name alone.
Fixed
Dates are now uniformly random when using therandcrate. 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.Changed
- MSRV is lowered to 1.32.0.
-
0.2.1009 Jul 2023Release notes
Open source →Added
- Support for formatting and parsing
OffsetDateTimes as RFC3339. - Lazy formatting. To avoid exposing implementation details, we're just returning
impl Display, rather than a concrete type. - Add support for Illumos.
Fixed
- Deprecated APIs from time v0.1 are public again. They were previously hidden by accident in 0.2.9.
- Support for formatting and parsing
-
0.2.906 May 2023Release notes
Open source →Fixed
cfg-ifnow has a mandatory minimum of 0.1.10, rather than just 0.1. This is because compilation fails when using 0.1.9. -
0.2.825 Feb 2023Release notes
Open source →Added
cargo_websupport has been added for getting a local offset. A general catch-all defaulting to UTC has also been added.Error::sourcehas 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,IndeterminateOffsetErrorhas been added.- Support for parsing and formatting subsecond nanoseconds.
Changed
#[non_exhaustive]is simulated on compilers prior to 1.40.0.
-
0.2.717 Feb 2023Release notes
Open source →Added
Displayhas been implemented forDate,OffsetDateTime,PrimitiveDateTime,Time,UtcOffset, andWeekday.Hashis now derived forDuration.SystemTimecan be converted to and fromOffsetDateTime. The following trait implementations have been made for interoperability:impl Sub<SystemTime> for OffsetDateTimeimpl Sub<OffsetDateTime> for SystemTimeimpl PartialEq<SystemTime> for OffsetDateTimeimpl PartialEq<OffsetDateTime> for SystemTimeimpl PartialOrd<SystemTime> for OffsetDateTimeimpl PartialOrd<OffsetDateTime> for SystemTimeimpl From<SystemTime> for OffsetDateTimeimpl From<OffsetDateTime> for SystemTime
- All structs now
impl Duration<T> for Standard, allowing usage with therandcrate. This is gated behind therandfeature flag. - Documentation can now be built on stable. Some annotations will be missing if you do this.
NumericalDurationhas been implemented forf32andf64.NumericalStdDurationandNumericalStdDurationShorthave been implemented forf64only.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().
Changed
- All formatting and parsing methods now accept
impl AsRef<str>as parameters, rather than just&str.time::validate_format_stringdoes this as well. - The requirement of a
Datebeing between the years -100,000 and +100,000 (inclusive) is now strictly enforced. - Overflow checks for
Durationare now enabled by default. This behavior is the identical to what the standard library does. - The
time,date, andoffsetmacros have been added to the prelude.
Deprecated
-
Signhas 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_zeromethods. -
A number of functions and trait implementations that implicitly assumed a timezone (generally UTC) have been deprecated. These are:
Date::todayTime::nowPrimitiveDateTime::nowPrimitiveDateTime::unix_epochPrimitiveDateTime::from_unix_timestampPrimitiveDateTime::timestampimpl Sub<SystemTime> for PrimitiveDateTimeimpl Sub<PrimitiveDateTime> for SystemTimeimpl PartialEq<SystemTime> for PrimitiveDateTimeimpl PartialEq<PrimitiveDateTime> for SystemTime>impl PartialOrd<SystemTime> for PrimitiveDateTimeimpl PartialOrd<PrimitiveDateTime> for SystemTime>impl From<SystemTime> for PrimitiveDateTimeimpl From<PrimitiveDateTime> for SystemTime
Fixed
- Avoid panics when parsing an empty string (#215).
- The nanoseconds component of a
Durationis now always in range. Previously, it was possible (via addition and/or subtraction) to obtain a value that was not internally consistent. Time::parseerroneously returned anInvalidMinuteerror when it was actually the second that was invalid.Date::parse("0000-01-01", "%Y-%m-%d")incorrectly returned anErr(#221).
-
0.2.606 Nov 2022Nothing published for this version
-
0.2.524 Oct 2022Nothing published for this version
-
0.2.422 Mar 2022Nothing published for this version
-
0.2.326 Sep 2021Nothing published for this version
-
0.2.225 Aug 2021Nothing published for this version
-
0.2.106 Aug 2021Nothing published for this version
-
0.2.030 Jul 2021Nothing published for this version
-
0.2.0-alpha.113 Jun 2021 pre-releaseNothing published for this version
-
0.2.0-alpha.022 Apr 2021 pre-releaseNothing published for this version
-
0.1.129 Sep 2020Nothing published for this version
-
0.1.017 Jan 2020Nothing published for this version
-
0.0.0-alpha.002 Dec 2019 pre-release withdrawnNothing published for this version