time
Date and time library. Fully interoperable with the standard library. Mostly compatible with #![no_std].
0.3.55
843M downloads/mo
#73 most downloaded on crates.io
time-rs/time
What this package is like to depend on
Last release 22 days ago
01 Aug 2026
Ships unpredictably
gaps range from 8 days to 6 months
Some releases are documented
notes for 73 of 124 stable releases
8 versions withdrawn
withdrawn after publishing
12 years old
135 releases · first in 2014
14 releases in the last 12 months
see the full history below
Release timeline
135 releases · Nov 2014 to Aug 2026Releases
latest 60 of 135-
0.3.5501 Aug 2026Release notes
Open source →Fixed
- Avoid underflow in
DateIter::nth, ensuring correct behavior. - Avoid overflow when deserializing timestamps.
- Handle out-of-bounds data when deserializing.
- Don't assume that the format being deserialized was generated by the serializer; this previously led to some valid values being parsed incorrectly and others being rejected.
- No longer silence errors when deserializing
UtcOffset. OffsetDateTime::from_unix_timestamp_nanosandUtcDateTime::from_unix_timestamp_nanoscorrectly returnNonefor all out-of-range values, rather than unexpectedly panicking in some situations.OffsetDateTime::checked_to_offsetandUtcDateTime::checked_to_offsetcorrectly returnNonefor all out-of-range values, rather than unexpectedly panicking in some situations.
- Avoid underflow in
-
0.3.5420 Jul 2026Release notes
Open source →Added
PrimitiveDateTimehas been renamed toPlainDateTime.Durationhas been renamed toSignedDuration.- Iteration is now possible over
Date,Month, andWeekday. Relevant iterator methods have been overridden to ensure maximum performance.
For both
PlainDateTimeandSignedDuration, a non-deprecated type alias has been added for backwards compatibility. The new names should be preferred.Changed
- The associated metadata type (for
powerfmtimplementations) for various types has been changed to()and made public. This guarantees that no additional metadata will be present.
Performance
- More gains when parsing RFC 2822.
-
0.3.5301 Jul 2026Release notes
Open source →There are no publicly-facing changes in this release. It solely works around the
cookiecrate relying on an implementation detail oftimethat was never part of the public API (and thus subject to semver guarantees). The internal API has been reverted to the extent necessary forcookieto compile. This measure is temporary; the internal change will be re-applied in an yet-to-be-determined future release. -
0.3.5230 Jun 2026Release notes
Open source →Fixed
- Subsecond values in the
time!macro are parsed using the textual representation, ensuring accuracy. Previously, they were parsed using the floating point representation, which could result in a loss of precision and even invalid values. - The
date!macro could previously create an invalid value that would then panic at compile time. The macro now emits a proper error instead. - When parsing an invalid format description, an edge case would inadvertently panic. This now returns an error as intended.
Added
- Support default values when parsing
- Subsecond values in the
-
0.3.5122 Jun 2026Release notes
Open source →Fixed
timecompiles withmacrosenabled. This version is otherwise identical to v0.3.50.
-
0.3.5022 Jun 2026 withdrawnRelease notes
Open source →This version was yanked because it would not compile when the
macrosfeature was enabled.Added
Timestamptype
Fixed
[year]in a runtime-parsed version 3 format description when thelarge-datesfeature is not enabled now succeeds. This previously failed due to a missing#[cfg].
Performance
- Further gains when parsing with the non-deprecated parts of the RFC 2822 well-known format
- Gains when formatting with the ISO 8601 well-known format
Datearithmetic is improved in common situations
-
0.3.4913 Jun 2026Release notes
Open source →Fixed
- Due to a long-standing bug in the Rust compiler, v0.3.48 caused a number of crates to stop compiling. A patch has been added that avoids triggering the bug.
-
0.3.4812 Jun 2026 withdrawnRelease notes
Open source →This version was yanked due to a bug in the Rust compiler.
Security
- The number of digits parsed by
[subsecond digits:1+]is capped at 32 to avoid parsing unbounded user input. Digits after the 9<sup>th</sup> have no semantic meaning. - Explicitly specify
#[repr]forWeekday. The value of the variants is relied upon in multiple locations for soundness. The practical effect of this change is nothing, as Rust has always mapped C-likeenums to 0..N in memory.
Compatibility
- Non-UTF-8 formatting and parsing is deprecated without replacement. It is recommended to only format and parse valid UTF-8.
format_description::parseis deprecated. It is recommended to useformat_description::parse_borrowed::<3>orformat_description::parse_owned::<3>.
Added
- All types in the
unitmodule have a generic parameter, though this is currently not used for much. Usage will be expanded in the future. - Comparisons between types in the
unitmodule and the genericUnittype are permitted. - Support for
rand0.10 - Version 3 format descriptions
- Only UTF-8 is supported. As a side effect of this,
[ignore]requires that the remaining input not begin mid-codepoint. - Representation is deliberately opaque to allow for arbitrary changes going forward.
format:falseis supported on[optional]components. This is not possible in version 1 and version 2 format descriptions due to API compatibility.- The
time::serde::format_description!macro uses a new, clearer syntax for version 3.time::serde::format_description!(mod foo [Date] = "[year]-[month]-[day]");- Unlike version 1 and version 2 format descriptions, the type is not automatically brought into scope. You must import it yourself.
- Nonsensical combinations of modifiers are rejected. For example, you cannot specify case-sensitivity when parsing a numerical month.
[year]defaults torange:standard- Components and modifiers are case sensitive (and always lowercase).
- Only UTF-8 is supported. As a side effect of this,
Changed
- The
convertmodule has been renamed tounit.
Fixed
- Macro hygiene has been improved by specifying re-exports.
- Fix handling of
Tin ISO 8601 - Support parsing the full range of UTC offset hours
- Version 1 nested format descriptions may now start with a component. Previously, a lexer bug unintentionally prohibited this.
- Error when ISO week date overflows the max year. This would previously panic.
- Error when padding is specified in
strftimeformat descriptions but the component is not. This would previously panic.
Performance
Huge performance gains across multiple areas, including:
- optimizing equality checks for
Duration - optimizing
Displayimpls for all major types - optimizing the formatting of components and well-known formats
- precomputing metadata when formatting, reducing allocations
- adding fast path for typical RFC 2822 usage
- optimizing
strftimeparsing - refactoring format description parsing
Depending on the area, gains range from 3× to even 11×.
- The number of digits parsed by
-
0.3.4705 Feb 2026Release notes
Open source →Security
-
The possibility of a stack exhaustion denial of service attack when parsing RFC 2822 has been eliminated. Previously, it was possible to craft input that would cause unbounded recursion. Now, the depth of the recursion is tracked, causing an error to be returned if it exceeds a reasonable limit.
This attack vector requires parsing user-provided input, with any type, using the RFC 2822 format.
Compatibility
- Attempting to format a value with a well-known format (i.e. RFC 3339, RFC 2822, or ISO 8601) will
error at compile time if the type being formatted does not provide sufficient information. This
would previously fail at runtime. Similarly, attempting to format a value with ISO 8601 that is
only configured for parsing (i.e.
Iso8601::PARSING) will error at compile time.
Added
- Builder methods for format description modifiers, eliminating the need for verbose initialization when done manually.
date!(2026-W01-2)is now supported. Previously, a space was required betweenWand01.[end]now has atrailing_inputmodifier which can either beprohibit(the default) ordiscard. When it isdiscard, all remaining input is ignored. Note that if there are components after[end], they will still attempt to be parsed, likely resulting in an error.
Changed
- More performance gains when parsing.
Fixed
- If manually formatting a value, the number of bytes written was one short for some components. This has been fixed such that the number of bytes written is always correct.
- The possibility of integer overflow when parsing an owned format description has been effectively
eliminated. This would previously wrap when overflow checks were disabled. Instead of storing the
depth as
u8, it is stored asu32. This would require multiple gigabytes of nested input to overflow, at which point we've got other problems and trivial mitigations are available by downstream users.
-
-
0.3.4624 Jan 2026Release notes
Open source →Added
-
All possible panics are now documented for the relevant methods.
-
The need to use
#[serde(default)]when using customserdeformats is documented. This applies only when deserializing anOption<T>. -
Duration::nanoseconds_i128has been made public, mirroringstd::time::Duration::from_nanos_u128. -
Various methods for truncating components have been added, avoiding the need to call the fallible
replacemethods multiple times.For
PrimitiveDateTime,UtcDateTime, andOffsetDateTime:truncate_to_day
For
Time,PrimitiveDateTime,UtcDateTime, andOffsetDateTime:truncate_to_hourtruncate_to_minutetruncate_to_secondtruncate_to_millisecondtruncate_to_microsecond
Changed
- The minimum supported Rust version is now 1.88.0.
- Significant performance gains in numerous locations. No public APIs were changed or removed as part of this.
- The size of
error::ComponentRange, along with types that contain it, has been significantly reduced.
Fixed
- The
PartialOrdandOrdimplementations ofUtcOffsetnow return the expected result.
-
-
0.3.4513 Jan 2026Release notes
Open source →Added
time::format_description::StaticFormatDescriptiontype alias for&'static [BorrowedFormatItem<'static>]. This is the type returned by thetime::macros::format_description!macro.
Changed
- The minimum supported Rust version is now 1.83.0.
- All floating point methods on
Durationare nowconst fn. - All setters on
Parsedare nowconst fn. - The
serdedependency has been replaced withserde_core, This reduces compile times by not including unused parts ofserde. Date::from_julian_dayuses a new algorithm, resulting in an approximately 16% performance improvement. This method is used internally by numerous other methods.util::is_leap_yearuses a new algorithm, resulting in an approximately 8% performance improvement.
-
0.3.4419 Sep 2025Release notes
Open source →Fixed
- Comparisons of
PrimitiveDateTime,UtcDateTime, andOffsetDateTimewith differing signs (i.e. one negative and one positive year) would return the inverse result of what was expected. This was introduced in v0.3.42 and has been fixed. - Type inference would fail due to feature unification when
wasm-bindgenenabledserde_json. This has been fixed by explicitly specifying the type in the relevant locations.
- Comparisons of
-
0.3.4302 Sep 2025Release notes
Open source →Added
- Support for
rand0.9
Fixed
- In the
convertmodule, any use ofperwith types that were not the same (such asNanosecond::per(Second)) would not compile due to a bug. This has been fixed.
- Support for
-
0.3.4231 Aug 2025Release notes
Open source →Added
Time::duration_untilTime::duration_sinceper_tmethod for all types intime::convert. This is similar to the existingpermethod, but can return any of the primitive numeric types that can represent the result. This will cut down onascasts while ensuring correctness. Type inference isn't perfect, so you may need to provide a type annotation in some situations.impl PartialOrd for Monthandimpl Ord for Month; this assumes the months are in the same yearSystemTimeExttrait, adding methods for checked arithmetic withtime::Durationand obtaining the difference between twoSystemTimes as atime::Duration- Permit using
UtcDateTimewithrand(this was inadvertently omitted previously) impl core::error::Errorfor all error types (now available when thestdfeature is disabled)- MacOS can now obtain the local UTC offset in multi-threaded programs as the system APIs are thread-safe.
#[track_caller]has been added to all relevant methods.
Changed
- The minimum supported Rust version is now 1.81.0.
- The dependency on
itoahas been removed, as the standard library now has similar functionality by default. - Formatting a component that involves a floating point number is now guaranteed to be deterministic, avoiding any subtle differences between platforms or compiler versions.
Fixed
- Serializing timestamps with nanosecond precision should always emit the correct value. Previously, it could be off by one nanosecond due to floating point imprecision.
- A previously unknown bug in
OffsetDateTime::to_offsetandUtcDateTime::to_offsethas been fixed. The bug could result in a value that was invalid. It was unlikely to ever occur in real-world code, as it involved passing a UTC offset that has never been used in any location.
Miscellaneous
- The amount of code generated by macros has been massively reduced, on the order of 65-70% for
typical use cases of
format_description!. - Significant performance gains for comparisons of
Time,PrimitiveDateTime,UtcDateTime, andOffsetDateTime. The first three have gains of approximately 85% (i.e. 6× faster). - Nearly all methods are
#[inline].
-
0.3.4123 Mar 2025Release notes
Open source →Fixed
- Compatibility with the latest release of
deranged. This fix is permanent and covers future similar changes upstream.
- Compatibility with the latest release of
-
0.3.4018 Mar 2025Release notes
Open source →Added
- Visibility modifiers may now be added to the
modgenerated bytime::sere::format_description!.
- Visibility modifiers may now be added to the
-
0.3.3906 Mar 2025Release notes
Open source →Fixed
- Doc tests run successfully with the default feature set.
- wasm builds work again.
Both of these were regressions in v0.3.38 and are now checked in CI.
-
0.3.3805 Mar 2025Release notes
Open source →Added
-
The
[year]component (in format descriptions) now supports arangemodifier, which can be eitherstandardorextended. The default isextendedfor backwards compatibility. This is intended as a manner to opt out of the extended range when thelarge-datesfeature is enabled. When thelarge-datesfeature is not enabled, the modifier has no effect. -
UtcDateTime, which is semantically equivalent to anOffsetDateTimewith UTC as its offset. The advantage is that it is the same size as aPrimitiveDateTimeand has improved operability with well-known formats.As part of this, there were some other additions:
utc_datetime!macro, which is similar to thedatetime!macro but constructs aUtcDateTime.PrimitiveDateTime::as_utcOffsetDateTime::to_utcOffsetDateTime::checked_to_utc
-
time::serde::timestamp::milliseconds_i64, which is a module to serialize/deserialize timestamps as the Unix timestamp. The pre-existing module does this as ani128where ani64would suffice. This new module should be preferred.
Changed
error::Formathas had itssource()implementation changed to no longer return a boxed value from theComponentRangevariant. If you were explicitly expecting this, you will need to update your code. The method API remains unchanged.[year repr:century]supports single-digit values.- All
format_intomethods accept?Sizedreferences.
Miscellaneous
- Some non-exhaustive enum variants that are no longer used have been modified to be statically proven as uninhabited. The relevant fields are doc-hidden and not semver-guaranteed to remain as such, though it is unlikely to change.
- An unnecessary check when parsing RFC 2822 has been removed.
- Various methods have had their implementations changed, resulting in significant performance
gains. Among the methods changed are
util::is_leap_yearutil::weeks_in_yearMonth::lengthDate::to_calendar_dateDate::monthDate::dayDate::from_julian_dayDate::to_julian_day- other methods that call into these methods
-
-
0.3.3703 Dec 2024Release notes
Open source →Added
Time::MAX, equivalent totime!(23:59:59.999999999)[year repr:century]is now supported in format descriptions. When used in conjunction with[year repr:last_two], there is sufficient information to parse a date. Note that with thelarge-datefeature enabled, there is an ambiguity when parsing the two back-to-back.- Parsing of
strftime-style format descriptions, located attime::format_description::parse_strftime_borrowedandtime::format_description::parse_strftime_owned time::util::refresh_tzandtime::util::refresh_tz_unchecked, which updates information obtained via theTZenvironment variable. This is equivalent to thetzsetsyscall on Unix-like systems, with and without built-in soundness checks, respectively.Month::lengthandutil::days_in_month, replacingutil::days_in_year_month.- Expressions are permitted in
time::serde::format_description!rather than only paths. This also drastically improves diagnostics when an invalid value is provided.
Changed
-
Obtaining the system UTC offset on Unix-like systems should now succeed when multi-threaded. However, if the
TZenvironment variable is altered, the program will not be aware of this untiltime::util::refresh_tzortime::util::refresh_tz_uncheckedis called.refresh_tzhas the same soundness requirements as obtaining the system UTC offset previously did, with the requirements still being automatically enforced.refresh_tz_uncheckeddoes not enforce these requirements at the expense of beingunsafe. Most programs should not need to call either function.Due to this change, the
time::util::local_offsetmodule has been deprecated in its entirety. Theget_soundnessandset_soundnessfunctions are now no-ops.Note that while calls should succeed, success is not guaranteed in any situation. Downstream users should always be prepared to handle the error case.
Fixed
- Floating point values are truncated, not rounded, when formatting.
- RFC3339 allows arbitrary separators between the date and time components.
- Serialization of negative
Durations less than one second is now correct. It previously omitted the negative sign. From<js_sys::Date> for OffsetDateTimenow ensures sub-millisecond values are not erroneously returned.
-
0.3.3611 Apr 2024Release notes
Open source →Fixed
FormatItemcan be used as part of an import path. See #675 for details.
-
0.3.3510 Apr 2024Release notes
Open source →Added
Duration::checked_negext::InstantExt, which provides methods for usingtime::Durationwithstd::time::Instant
Changed
Instantis deprecated. It is recommended to usestd::time::Instantdirectly, importingtime::ext::InstantExtfor interoperability withtime::Duration.FormatItemhas been renamed toBorrowedFormatItem, avoiding confusion withOwnedFormatItem. An alias has been added for backwards compatibility.
Fixed
- The weekday is optional when parsing RFC2822.
- The range of sub-second values in
Durationis documented correctly. The previous documentation contained an off-by-one error. - Leap seconds are now correctly handled when parsing ISO 8601.
-
0.3.3403 Feb 2024Release notes
Open source →Fixed
Computing the local offset on Windows works again. It was broken in some cases in v0.3.32 and v0.3.33.
-
0.3.3303 Feb 2024 -
0.3.3201 Feb 2024Release notes
Open source →Added
- Methods to replace the day of the year.
Date::replace_ordinalPrimitiveDateTime::replace_ordinalOffsetDateTime::replace_ordinal
- Modules to treat an
OffsetDateTimeas a Unix timestamp with subsecond precision for serde.time::serde::timestamp::millisecondstime::serde::timestamp::microsecondstime::serde::timestamp::nanoseconds
Changed
Duration::time_fnis deprecated.
- Methods to replace the day of the year.
-
0.3.3119 Dec 2023Release notes
Open source →Added
OffsetDateTime::new_in_offsetOffsetDateTime::new_utc
Changed
- The valid range of
UtcOffsethas been expanded from ±23:59:59 to ±25:59:59. This is to support the full POSIX range while permitting infallible negation.
-
0.3.3014 Oct 2023Release notes
Open source →Added
powerfmt::smart_display::SmartDisplayhas been added for the main types in the library. These implementations ensure that values follow the requested fill, width, and alignment when usingformat!or similar macros.Displayis implemented in terms ofSmartDisplay.
Fixed
- Large values no longer wrap around in release mode when using
NumericalDurationorNumericalStdDuration.
-
0.3.2924 Sep 2023Release notes
Open source →Added
-
Niche value optimization for
Datehas been added. BothDateandOption<Date>are four bytes. -
Unit conversions have been added. It is now possible to write
Second::per(Day), which returns the number of seconds in one day. See the types in thetime::convertmodule for more information.
Changed
- The diagnostic for
--cfg unsound_local_offsethas been removed. #![feature(no_coverage)]was previously used internally for code coverage. It is no longer used, so it has been removed.- The default value for
modifier::OffsetHourhas been changed. This was unintentionally changed in v0.3.17 and went unnoticed until now. The sign is now only present if needed by default, as was the case previously. This does not affect any situation whereformat_description!orformat_description::parseis used.
Fixed
- Adding or subtracting a
std::time::Durationto/from anOffsetDateTimewill not result in integer overflow internally. It will still panic if the result is out of range.
-
-
0.3.2827 Aug 2023Release notes
Open source →Added
- More additional constants for the well-known
Iso8601format description have been added. This avoids the need to manually configure the format. - An
[end]component has been added. This is ignored during formatting, but is used to indicate the end of input when parsing. If any input remains after this component, an error is returned. This is useful when using the[first]component, as it avoids the need to reorder variants.
Changed
- The exemption for MacOS introduced in 0.3.20 has been removed. This is because some supported versions of MacOS do not meet the requirements for the exemption.
- The
UnexpectedTrailingCharacterserror variant has been moved toParseFromDescription. All previously-existing locations of this variant have been deprecated and will no longer be returned.
- More additional constants for the well-known
-
0.3.2722 Aug 2023Release notes
Open source →This sets the
serdedependency requirement to>= 1.0.184where the binaries have been removed. -
0.3.2618 Aug 2023Release notes
Open source →This release contains only a single change.
serdeis required to be a version prior to 1.0.171. This is due to the decision by the maintainer ofserdeto include pre-built binaries that are executed without the end user's knowledge. As of the time of publishing, the included binary has not even been reproduced. This is a security risk, and thetimeproject strongly opposes this decision. While this may break some users' builds due to conflicting versions, it is a necessary step to ensure the security. -
0.3.2502 Aug 2023Release notes
Open source →Fixed
- Methods such as
Time::replace_millisecondswould panic on some out-of-range values. This has been fixed.
- Methods such as
-
0.3.2430 Jul 2023Release notes
Open source →Added
- The
subsecondcomponent is taken into account when parsing theunix_timestampcomponent. If data is conflicting, thesubsecondvalue takes precedence. - Parsing a
Timewith only thehourcomponent is now supported. Theminuteandsecond, andsubsecondcomponents are assumed to be zero.
Changed
- The minimum supported Rust version is now 1.67.0.
- The debug output for
Parsedhas been improved. - When parsing, invalid values are now rejected sooner. Previously, the entire input would be parsed before being rejected in the final step. Now, invalid values are rejected as soon as they are encountered. This affects the error variant returned, which may cause minor breakage for any code (incorrectly) relying on the exact error variant.
- When parsing a
Time, an error is returned if components are present but not consecutive. For example, ifhoursandsecondsare present,minuteswill not be assumed to be zero.
Fixed
- The implementation of
Duration::checked_divcould return a slightly incorrect result in some cases. This has been fixed.
- The
-
0.3.2309 Jul 2023Release notes
Open source →Added
Date::next_occurrenceDate::prev_occurrenceDate::nth_next_occurrenceDate::nth_prev_occurrenceWeekday::nth_prevMonth::nth_nextMonth::nth_prev
Changed
The minimum supported Rust version policy has been updated. See the README for details.
Fixed
Duration::abscorrectly returnsDuration::MAXwhen near the minimum value. The nanoseconds value was previously incorrect.- Compliance with ISO 8601 has been improved. Previously, a UTC offset would be incorrectly rejected in some cases.
-
0.3.2207 Jun 2023 -
0.3.2106 May 2023Release notes
Open source →Added
- Any formattable/parsable type can now be used with the
time::serde::format_description!macro. Weekday::nth_next
Changed
- The minimum supported Rust version is now 1.65.0.
- Any formattable/parsable type can now be used with the
-
0.3.2025 Feb 2023Release notes
Open source →Changed
- The minimum supported Rust version is now 1.63.0.
- On Unix-based operating systems with known thread-safe environments, functions obtaining the local offset no longer require a check that the program is single-threaded. This currently includes MacOS, illumos, and NetBSD.
Added
[ignore]component in format descriptions. Acountmodifier is required, indicating the number of bytes to ignore when parsing.[unix_timestamp]component in format descriptions. This is currently only usable withOffsetDateTime. Users can choose between seconds, milliseconds, microseconds, and nanoseconds, and whether the sign is mandatory or optional.
Fixed
- The API for declaring soundness now uses stricter atomic orderings internally.
-
0.3.1917 Feb 2023Release notes
Open source →Fixed
This includes the update to the
format_description!macro, which was supposed to be included in 0.3.18. -
0.3.1816 Feb 2023Release notes
Open source →Changed
- The minimum supported Rust version is now 1.62.0.
Added
[first]and[optional]items can now be included in format descriptions. To parse this at runtime, you must use theformat_description::parse_ownedmethod.format_description::parse_borrowed- An API has been added to opt out of soundness checks for obtaining the local offset. This replaces
the previous, officially unsupported
RUSTFLAGS="--cfg unsound_local_offset". End users may calltime::util::local_offset::set_soundness(time::util::local_offset::Soundness::Unsound). This method isunsafebecause it enables undefined behavior if its safety requirements are not upheld. Note that libraries must not set this toUnsound, as it is impossible for a library to guarantee end users uphold the required invariants.
Fixed
- Correctly parse offset sign when hour is zero. The parse was previously unconditionally positive, even if the sign indicated otherwise.
- Compilation is fixed for WebAssembly.
-
0.3.1706 Nov 2022Release notes
Open source →Changed
- The amount of code generated by
time::serde::format_description!is reduced if not all feature flags are active. cargo test --testsworks with any configuration of feature flags. This occurs by spawning a subprocess that passes--all-features.cargo test --docworks with most combinations of feature flags, including the default. The combination of these changes means that crater will now run ontime.libcandnum_threadsare only included as dependencies when needed. They were previously unconditionally included.
Added
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 newOwnedFormatItemis usable for both formatting and parsing, as you would expect.
Compatibility
- 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 amount of code generated by
-
0.3.1624 Oct 2022Release notes
Open source →Changed
- The minimum supported Rust version is now 1.60.0.
- The
serde-well-knownfeature 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.
Added
-
consts can now be provided as the format description fortime::serde::format_description!. Theconstmust 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);
Compatibility
- Some feature flags have been removed. None of these have ever been documented as flags, so any use
was unsupported. These flags are:
js-sysquickcheck-depitoatime-macros
-
0.3.1504 Oct 2022Release notes
Open source →Changed
- Better gating for
tm_gmtoffextension. This should eliminate build failures on some untested platforms. Debugoutput 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
NaNis passed toDuration::from_secs_f32orDuration::from_secs_f64.
Fixed
- Fix error when deserializing data types from bytes. This affects formats such as JSON.
- Eliminate a panic in an edge case when converting
OffsetDateTimeto anotherUtcOffset. This occurred due to an old assumption in code that was no longer the case.
- Better gating for
-
0.3.1425 Aug 2022Release notes
Open source →Changed
- The minimum supported Rust version is now 1.59.0.
Duration::unsigned_absis nowconst fn.- The const parameter for
time::format_description::well_known::Iso8601now has a default. This meansIso8601is the same asIso8601::DEFAULT. - The
Parsedstruct has been reduced in size from 56 to 32 bytes (a 43% reduction).
-
0.3.1309 Aug 2022 -
0.3.1201 Aug 2022Release notes
Open source →Added
js-sysnow supports obtaining the system's local UTC offset.
Changed
- Performance of many
Dateoperations has improved when using thelarge-datesfeature. - While an internal change,
OffsetDateTimenow stores the value in the attachedUtcOffset, not UTC. This leads to significant performance gains on nearly allOffsetDateTimemethods.
Fixed
- Subtracting two
Times 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.
-
0.3.1122 Jun 2022 -
0.3.1020 Jun 2022Release notes
Open source →Added
- Serde support for non-self-describing formats
Duration::unsigned_abs, which returns astd::time::Duration- ISO 8601 well-known format
Durationcan now be formatted with a.Nspecifier, providing a shorter representation when usingDisplay.- Parse
nullasNoneon serde structs
Fixed
- Fix incorrect parsing of UTC offset in
Rfc3339.
Changed
- The minimum supported Rust version is now 1.57.0.
- Performance for
Rfc2822has 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.
-
0.3.922 Mar 2022Release notes
Open source →Added
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_yearDate::replace_monthDate::replace_dayTime::replace_hourTime::replace_minuteTime::replace_secondTime::replace_millisecondTime::replace_microsecondTime::replace_nanosecondPrimitiveDateTime::replace_yearPrimitiveDateTime::replace_monthPrimitiveDateTime::replace_dayPrimitiveDateTime::replace_hourPrimitiveDateTime::replace_minutePrimitiveDateTime::replace_secondPrimitiveDateTime::replace_millisecondPrimitiveDateTime::replace_microsecondPrimitiveDateTime::replace_nanosecondOffsetDateTime::replace_yearOffsetDateTime::replace_monthOffsetDateTime::replace_dayOffsetDateTime::replace_hourOffsetDateTime::replace_minuteOffsetDateTime::replace_secondOffsetDateTime::replace_millisecondOffsetDateTime::replace_microsecondOffsetDateTime::replace_nanosecondParsed::offset_minute_signedParsed::offset_second_signedParsed::set_offset_minute_signedParsed::set_offset_second_signedParsed::with_offset_minute_signedParsed::with_offset_second_signederror::InvalidVariantimpl FromStrforWeekdayimpl FromStrforMonthimpl Display for Duration
Deprecated
The following methods have been deprecated in favor of the new, signed equivalent methods. The pre-existing methods
Parsed::offset_minuteParsed::offset_secondParsed::set_offset_minuteParsed::set_offset_secondParsed::with_offset_minuteParsed::with_offset_second
Changed
- Well-known formats that support leap seconds now return the
TryFromParsed::ComponentRangeerror variant if the leap second could not occur at that given moment.
-
0.3.822 Mar 2022 withdrawn -
0.3.726 Jan 2022 -
0.3.621 Jan 2022Release notes
Open source →Added
Date::saturating_addDate::saturating_subPrimitiveDateTime::saturating_addPrimitiveDateTime::saturating_subOffsetDateTime::saturating_addOffsetDateTime::saturating_subPrimitiveDatetime::MINPrimitiveDatetime::MAXRfc2822format description- Serde support for well-known formats
- This is placed behind the new
serde-well-knownfeature flag.
- This is placed behind the new
Changed
- MacOS and FreeBSD are supported obtaining the local offset when single-threaded.
- Starting with this version, this is delegated to the
num_threadscrate.
- 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.
Fixed
- Deserialization will no longer fail when given a non-borrowed string.
-
0.3.512 Nov 2021Release notes
Open source →Added
Date::checked_addDate::checked_subPrimitiveDateTime::checked_addPrimitiveDateTime::checked_subOffsetDateTime::checked_addOffsetDateTime::checked_sub
Changed
- 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
Errvalue for any reason.
-
0.3.426 Oct 2021Release notes
Open source →Added
error::DifferentVariantandError::DifferentVariantimpl From<Component> for FormatItem<'_>impl TryFrom<FormatItem<'_>> for Componentimpl<'a> From<&'a [FormatItem<'_>]> for FormatItem<'a>impl<'a> TryFrom<FormatItem<'a>> for &[FormatItem<'a>]impl PartialEq<Component> for FormatItem<'_>impl PartialEq<FormatItem<'_>> for Componentimpl PartialEq<&[FormatItem<'_>]> for FormatItem<'_>impl PartialEq<FormatItem<'_>> for &[FormatItem<'_>]impl TryFrom<Error> for error::TryFromParsedimpl TryFrom<Error> for error::Parseimpl TryFrom<Error> for error::ParseFromDescriptionimpl TryFrom<Error> for error::InvalidFormatDescriptionimpl TryFrom<Error> for error::IndeterminateOffsetimpl TryFrom<Error> for error::Formatimpl TryFrom<Error> for error::ConversionRangeimpl TryFrom<Error> for error::ComponentRangeimpl TryFrom<error::TryFromParsed> for error::ComponentRangeimpl TryFrom<error::Parse> for error::TryFromParsedimpl TryFrom<error::Parse> for error::ParseFromDescriptionimpl TryFrom<error::Format> for std::io::Errorimpl Sum for Durationimpl Sum<&Duration> for Duration- A
const fn default()has been added to all modifiers that arestructs. These methods exist to permit construction inconstcontexts and may be removed (without being considered a breaking change) onceimpl const Defaultis 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.
Fixed
- Cross-building to Windows now succeeds.
- A parse error on a
UtcOffsetcomponent now indicates the error comes from the offset. - Some arithmetic no longer panics in edge cases.
-
0.3.326 Sep 2021Release notes
Open source →Added
Parsed::parse_itemParsed::parse_itemsParsed::parse_literal- Builder methods for
Parsed - The
format_description!macro now supports thecase_sensitivemodifier.
Changed
The minimum supported version is now 1.51.0.
-
0.3.225 Aug 2021Release notes
Open source →Added
Instantis now#[repr(transparent)]
Fixed
- Constructing a
Datefrom 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_datemethod and thedate!macro.
-
0.3.106 Aug 2021Release notes
Open source →Added
Monthnow 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.
Fixed
- Macros that have a time component (
time!anddatetime!) no longer accept "0:00 AM" and similar. This was previously erroneously accepted.
-
0.3.030 Jul 2021Release notes
Open source →Added
datetime!macro, which allows the construction of a statically verifiedPrimitiveDateTimeorOffsetDateTime.PrimitiveDateTime::replace_timePrimitiveDateTime::replace_dateOffsetDateTime::replace_timeOffsetDateTime::replace_dateOffsetDateTime::replace_date_timeOffsetDateTime::replace_offset#![no_alloc]supportDate::to_iso_week_date, replacingDate::iso_year_weekDate::MINDate::MAXUtcOffset::from_hmsUtcOffset::from_whole_secondsUtcOffset::as_hmsUtcOffset::whole_hoursUtcOffset::whole_minutesUtcOffset::minutes_past_hourUtcOffset::seconds_past_minuteUtcOffset::is_utcUtcOffset::is_positiveUtcOffset::is_negativeOffsetDateTime::sunday_based_weekOffsetDateTime::monday_based_weekPrimitiveDateTime::to_calendar_datePrimitiveDateTime::to_ordinal_datePrimitiveDateTime::to_iso_week_datePrimitiveDateTime::to_julian_dayOffsetDateTime::to_calendar_dateOffsetDateTime::to_ordinal_dateOffsetDateTime::to_iso_week_dateOffsetDateTime::to_julian_dayTime::as_hmsTime::as_hms_milliTime::as_hms_microTime::as_hms_nanoPrimitiveDateTime::as_hmsPrimitiveDateTime::as_hms_milliPrimitiveDateTime::as_hms_microPrimitiveDateTime::as_hms_nanoOffsetDateTime::to_hmsOffsetDateTime::to_hms_milliOffsetDateTime::to_hms_microOffsetDateTime::to_hms_nanoDuration::saturating_addDuration::saturating_subDuration::saturating_mulutil::days_in_year_monthMonthInstant::into_innerimpl 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.
Changed
- 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
macrosfeature flag. - Renamed
OffsetDatetime::timestamp→OffsetDateTime::unix_timestampOffsetDatetime::timestamp_nanos→OffsetDateTime::unix_timestamp_nanosDate::try_from_ymd→Date::from_calendar_dateDate::try_from_yo→Date::from_ordinal_dateDate::try_from_iso_ywd→Date::from_iso_week_dateDate::as_ymd→Date::to_calendar_dateDate::as_yo→Date::to_ordinal_dateDate::try_with_hms→Date::with_hmsDate::try_with_hms_milli→Date::with_hms_milliDate::try_with_hms_micro→Date::with_hms_microDate::try_with_hms_nano→Date::with_hms_nanoTime::try_from_hms→Time::from_hmsTime::try_from_hms_milli→Time::from_hms_milliTime::try_from_hms_micro→Time::from_hms_microTime::try_from_hms_nano→Time::from_hms_nanoUtcOffset::try_local_offset_at→UtcOffset::local_offset_atUtcOffset::as_seconds→UtcOffset::whole_secondsOffsetDateTime::try_now_local→OffsetDateTime::now_localDate::week→Date::iso_weekPrimitiveDateTime::week→PrimitiveDateTime::iso_weekOffsetDateTime::week→OffsetDateTime::iso_weekDate::julian_day→Date::to_julian_day- All
Durationunit values, as well as the minimum and maximum, are now associated constants. OffsetDateTime::unix_epoch()→OffsetDateTime::UNIX_EPOCHTime::midnight()→Time::MIDNIGHT
- Now
const fn(on at least newer compilers)Date::weekdayDate::next_dayDate::previous_dayPrimitiveDateTime::assume_offsetPrimitiveDateTime::weekdayDuration::checked_addDuration::checked_subDuration::checked_mulOffsetDateTime::from_unix_timestampOffsetDateTime::from_unix_timestamp_nanosOffsetDateTime::dateOffsetDateTime::timeOffsetDateTime::yearOffsetDateTime::monthOffsetDateTime::dayOffsetDateTime::ordinalOffsetDateTime::to_iso_week_dateOffsetDateTime::weekOffsetDateTime::weekdayOffsetDateTime::hourOffsetDateTime::minuteOffsetDateTime::secondOffsetDateTime::millisecondOffsetDateTime::microsecondOffsetDateTime::nanosecondOffsetDateTime::unix_timestampOffsetDateTime::unix_timestamp_nanos
- The following functions now return a
Result:Date::from_julian_dayOffsetDateTime::from_unix_timestampOffsetDateTime::from_unix_timestamp_nanos
- The following functions now return an
Option:Date::next_dayDate::previous_day
- The range of valid years has changed. By default, it is ±9999. When using the
large-datesfeature, 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-offsetfeature:UtcOffset::local_offset_atOffsetDateTime::now_local
Instantis 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_daynow returns ani32(wasi64).Date::from_julian_daynow 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
Monthenum is used instead of numerical values where appropriate.
Removed
- v0.1 APIs, previously behind an enabled-by-default feature flag
PreciseTimeSteadyTimeprecise_time_nsprecise_time_sInstant::toDuration::num_weeksDuration::num_daysDuration::num_hoursDuration::num_minutesDuration::num_secondsDuration::num_millisecondsDuration::num_microsecondsDuration::num_nanosecondsDuration::spanDuration::from_stdDuration::to_std
- Panicking APIs, previously behind a non-default feature flag
Date::from_ymdDate::from_yoDate::from_iso_ywdDate::with_hmsDate::with_hms_milliDate::with_hms_microDate::with_hms_nanoTime::from_hmsTime::from_hms_milliTime::from_hms_microTime::from_hms_nano
- APIs that assumed an offset of UTC, previously enabled unconditionally
Date::todayTime::nowPrimitiveDateTime::nowPrimitiveDateTime::unix_epochPrimitiveDateTime::from_unix_timestampPrimitiveDateTime::timestampOffsetDateTime::nowimpl Sub<SystemTime> for PrimitiveDateTimeimpl Sub<PrimitiveDateTime> for SystemTimeimpl PartialEq<SystemTime> for PrimitiveDateTimeimpl PartialEq<PrimitiveDateTime> for SystemTimeimpl PartialOrd<SystemTime> for PrimitiveDateTimeimpl PartialOrd<PrimitiveDateTime> for SystemTimeimpl From<SystemTime> for PrimitiveDateTimeimpl From<PrimitiveDateTime> for SystemTimeUtcOffset::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::signPrimitiveDateTime::using_offsetSign
- Re-exports of APIs moved during the course of 0.2
days_in_yearis_leap_yearvalidate_format_stringweeks_in_yearComponentRangeErrorConversionRangeErrorIndeterminateOffsetErrorParseErrorNumericalDurationNumericalStdDurationNumericalStdDurationShort- 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_formatDate::lazy_formatUtcOffset::lazy_formatPrimitiveDateTime::lazy_formatOffsetDateTime::lazy_format
- Support for stdweb has been removed, as the crate is unmaintained.
- The
preludemodule has been removed in its entirety. Date::iso_year_weekin favor ofDate::to_iso_week_datePrimitiveDateTime::iso_year_weekOffsetDateTime::iso_year_weekUtcOffset::east_hoursUtcOffset::west_hoursUtcOffset::hoursUtcOffset::east_minutesUtcOffset::west_minutesUtcOffset::minutesUtcOffset::east_secondsUtcOffset::west_secondsUtcOffset::secondsDate::month_dayPrimitiveDateTime::month_dayOffsetDateTime::month_dayWeekday::iso_weekday_number(identical toWeekday::number_from_monday)ext::NumericalStdDurationShort
-
0.3.0-alpha-213 Jun 2021 pre-releaseNothing published for this version
-
0.3.0-alpha-127 May 2021 pre-releaseNothing published for this version
-
0.3.0-alpha-022 Apr 2021 pre-releaseNothing published for this version
-
0.2.2713 Jun 2021Nothing published for this version