Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
0.3.5→0.3.47Release Notes
time-rs/time (time)
v0.3.47Compare 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
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
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 componentsafter
[end], they will still attempt to be parsed, likely resulting in an error.Changed
Fixed
This has been fixed such that the number of bytes written is always correct.
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 tooverflow, at which point we've got other problems and trivial mitigations are available by
downstream users.
v0.3.46Compare Source
Added
All possible panics are now documented for the relevant methods.
The need to use
#[serde(default)]when using customserdeformats is documented. This appliesonly when deserializing an
Option<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_dayFor
Time,PrimitiveDateTime,UtcDateTime, andOffsetDateTime:truncate_to_hourtruncate_to_minutetruncate_to_secondtruncate_to_millisecondtruncate_to_microsecondChanged
part of this.
error::ComponentRange, along with types that contain it, has been significantlyreduced.
Fixed
PartialOrdandOrdimplementations ofUtcOffsetnow return the expected result.v0.3.45Compare Source
Added
time::format_description::StaticFormatDescriptiontype alias for&'static [BorrowedFormatItem<'static>]. This is the type returned by thetime::macros::format_description!macro.Changed
Durationare nowconst fn.Parsedare nowconst fn.serdedependency has been replaced withserde_core, This reduces compile times by notincluding unused parts of
serde.Date::from_julian_dayuses a new algorithm, resulting in an approximately 16% performanceimprovement. This method is used internally by numerous other methods.
util::is_leap_yearuses a new algorithm, resulting in an approximately 8% performanceimprovement.
v0.3.44Compare Source
Fixed
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.
wasm-bindgenenabledserde_json.This has been fixed by explicitly specifying the type in the relevant locations.
v0.3.43Compare Source
Added
rand0.9Fixed
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.v0.3.42Compare Source
Added
Time::duration_untilTime::duration_sinceper_tmethod for all types intime::convert. This is similar to the existingpermethod, butcan return any of the primitive numeric types that can represent the result. This will cut down on
ascasts while ensuring correctness. Type inference isn't perfect, so you may need to provide atype 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 obtainingthe difference between two
SystemTimes as atime::DurationUtcDateTimewithrand(this was inadvertently omitted previously)impl core::error::Errorfor all error types (now available when thestdfeature is disabled)thread-safe.
#[track_caller]has been added to all relevant methods.Changed
itoahas been removed, as the standard library now has similar functionalityby default.
deterministic, avoiding any subtle differences between platforms or compiler versions.
Fixed
Previously, it could be off by one nanosecond due to floating point imprecision.
OffsetDateTime::to_offsetandUtcDateTime::to_offsethas beenfixed. 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
typical use cases of
format_description!.Time,PrimitiveDateTime,UtcDateTime, andOffsetDateTime. The first three have gains of approximately 85% (i.e. 6× faster).#[inline].v0.3.41Compare Source
Fixed
deranged. This fix is permanent and covers futuresimilar changes upstream.
v0.3.40Compare Source
Added
modgenerated bytime::sere::format_description!.v0.3.39Compare Source
Fixed
Both of these were regressions in v0.3.38 and are now checked in CI.
v0.3.38Compare Source
Added
The
[year]component (in format descriptions) now supports arangemodifier, which can beeither
standardorextended. The default isextendedfor backwards compatibility. This isintended as a manner to opt out of the extended range when the
large-datesfeature is enabled.When the
large-datesfeature is not enabled, the modifier has no effect.UtcDateTime, which is semantically equivalent to anOffsetDateTimewith UTC as its offset. Theadvantage is that it is the same size as a
PrimitiveDateTimeand has improved operability withwell-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_utctime::serde::timestamp::milliseconds_i64, which is a module to serialize/deserialize timestampsas the Unix timestamp. The pre-existing module does this as an
i128where ani64wouldsuffice. This new module should be preferred.
Changed
error::Formathas had itssource()implementation changed to no longer return a boxed valuefrom the
ComponentRangevariant. If you were explicitly expecting this, you will need to updateyour code. The method API remains unchanged.
[year repr:century]supports single-digit values.format_intomethods accept?Sizedreferences.Miscellaneous
proven as uninhabited. The relevant fields are doc-hidden and not semver-guaranteed to remain as
such, though it is unlikely to change.
gains. Among the methods changed are
util::is_leap_yearutil::weeks_in_yearMonth::lengthDate::to_calendar_dateDate::monthDate::dayDate::from_julian_dayDate::to_julian_dayv0.3.37Compare 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.strftime-style format descriptions, located attime::format_description::parse_strftime_borrowedandtime::format_description::parse_strftime_ownedtime::util::refresh_tzandtime::util::refresh_tz_unchecked, which updates informationobtained via the
TZenvironment variable. This is equivalent to thetzsetsyscall on Unix-likesystems, with and without built-in soundness checks, respectively.
Month::lengthandutil::days_in_month, replacingutil::days_in_year_month.time::serde::format_description!rather than only paths. This alsodrastically 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 thesame soundness requirements as obtaining the system UTC offset previously did, with the
requirements still being automatically enforced.
refresh_tz_uncheckeddoes not enforce theserequirements at the expense of being
unsafe. Most programs should not need to call eitherfunction.
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
Durations less than one second is now correct. It previously omittedthe negative sign.
From<js_sys::Date> for OffsetDateTimenow ensures sub-millisecond values are not erroneouslyreturned.
v0.3.36Compare Source
Fixed
FormatItemcan be used as part of an import path. See #675 for details.v0.3.35Compare Source
Added
Duration::checked_negext::InstantExt, which provides methods for usingtime::Durationwithstd::time::InstantChanged
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
Durationis documented correctly. The previous documentationcontained an off-by-one error.
v0.3.34Compare Source
Fixed
Computing the local offset on Windows works again. It was broken in some cases in v0.3.32 and
v0.3.33.
v0.3.33Compare Source
Fixed
Builds targeting
wasm32-unknown-unknownnow work again.v0.3.32Compare Source
Added
Date::replace_ordinalPrimitiveDateTime::replace_ordinalOffsetDateTime::replace_ordinalOffsetDateTimeas a Unix timestamp with subsecond precision for serde.time::serde::timestamp::millisecondstime::serde::timestamp::microsecondstime::serde::timestamp::nanosecondsChanged
Duration::time_fnis deprecated.v0.3.31Compare Source
Added
OffsetDateTime::new_in_offsetOffsetDateTime::new_utcChanged
UtcOffsethas been expanded from ±23:59:59 to ±25:59:59. This is to supportthe full POSIX range while permitting infallible negation.
v0.3.30Compare Source
Added
powerfmt::smart_display::SmartDisplayhas been added for the main types in the library. Theseimplementations ensure that values follow the requested fill, width, and alignment when using
format!or similar macros.Displayis implemented in terms ofSmartDisplay.Fixed
NumericalDurationorNumericalStdDuration.v0.3.29Compare Source
Added
Datehas been added. BothDateandOption<Date>are four bytes.Second::per(Day), which returnsthe number of seconds in one day. See the types in the
time::convertmodule for moreinformation.
Changed
--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.
modifier::OffsetHourhas been changed. This was unintentionally changed inv0.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 where
format_description!orformat_description::parseis used.Fixed
std::time::Durationto/from anOffsetDateTimewill not result ininteger overflow internally. It will still panic if the result is out of range.
v0.3.28Compare Source
Added
Iso8601format description have been added. Thisavoids the need to manually configure the format.
[end]component has been added. This is ignored during formatting, but is used to indicatethe 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
versions of MacOS do not meet the requirements for the exemption.
UnexpectedTrailingCharacterserror variant has been moved toParseFromDescription. Allpreviously-existing locations of this variant have been deprecated and will no longer be returned.
v0.3.27Compare Source
This sets the
serdedependency requirement to>= 1.0.184where the binaries have been removed.v0.3.26Compare 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 of
serdeto include pre-built binaries that areexecuted 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 the
timeproject strongly opposes thisdecision. While this may break some users' builds due to conflicting versions, it is a necessary
step to ensure the security.
v0.3.25Compare Source
Fixed
Time::replace_millisecondswould panic on some out-of-range values. This hasbeen fixed.
v0.3.24Compare Source
Added
subsecondcomponent is taken into account when parsing theunix_timestampcomponent. Ifdata is conflicting, the
subsecondvalue takes precedence.Timewith only thehourcomponent is now supported. Theminuteandsecond, andsubsecondcomponents are assumed to be zero.Changed
Parsedhas been improved.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.
Time, an error is returned if components are present but not consecutive. Forexample, if
hoursandsecondsare present,minuteswill not be assumed to be zero.Fixed
Duration::checked_divcould return a slightly incorrect result in somecases. This has been fixed.
v0.3.23Compare Source
Added
Date::next_occurrenceDate::prev_occurrenceDate::nth_next_occurrenceDate::nth_prev_occurrenceWeekday::nth_prevMonth::nth_nextMonth::nth_prevChanged
The minimum supported Rust version policy has been updated. See the README for
details.
Fixed
Duration::abscorrectly returnsDuration::MAXwhen near the minimum value. The nanosecondsvalue was previously incorrect.
in some cases.
v0.3.22Compare Source
Added
OffsetDateTime::checked_to_offsetv0.3.21Compare Source
Added
time::serde::format_description!macro.Weekday::nth_nextChanged
v0.3.20Compare Source
Changed
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 numberof 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
v0.3.19Compare Source
Fixed
This includes the update to the
format_description!macro, which was supposed to be included in0.3.18.
v0.3.18Compare Source
Changed
Added
[first]and[optional]items can now be included in format descriptions. To parse this atruntime, you must use the
format_description::parse_ownedmethod.format_description::parse_borrowedthe previous, officially unsupported
RUSTFLAGS="--cfg unsound_local_offset". End users may calltime::util::local_offset::set_soundness(time::util::local_offset::Soundness::Unsound). Thismethod is
unsafebecause it enables undefined behavior if its safety requirements are notupheld. Note that libraries must not set this to
Unsound, as it is impossible for a libraryto guarantee end users uphold the required invariants.
Fixed
even if the sign indicated otherwise.
v0.3.17Compare Source
Changed
time::serde::format_description!is reduced if not all featureflags are active.
cargo test --testsworks with any configuration of feature flags. This occurs by spawning asubprocess that passes
--all-features.cargo test --docworks with most combinations offeature flags, including the default. The combination of these changes means that crater will now
run on
time.libcandnum_threadsare only included as dependencies when needed. They were previouslyunconditionally included.
Added
time::format_description::parse_owned, which returns anOwnedFormatItem. This avoids "lifetimehell", where all your structs now need a lifetime because a single field has one. Note that when
possible, the borrowed format item (just called
FormatItem) is still preferred, as it hassignificantly fewer allocations. The new
OwnedFormatItemis usable for both formatting andparsing, as you would expect.
Compatibility
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.
v0.3.16Compare Source
Changed
serde-well-knownfeature flag is deprecated. The necessary features for an item to beenabled are indicated in documentation.
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.Compatibility
was unsupported. These flags are:
js-sysquickcheck-depitoatime-macrosv0.3.15Compare Source
Changed
tm_gmtoffextension. This should eliminate build failures on some untestedplatforms.
Debugoutput for types are now human-readable. While this should not be relied upon, it iscurrently the same as the output with
Display.panic. This was previously only the case in debug mode.
NaNis passed toDuration::from_secs_f32orDuration::from_secs_f64.Fixed
OffsetDateTimeto anotherUtcOffset. Thisoccurred due to an old assumption in code that was no longer the case.
v0.3.14Compare Source
Changed
Duration::unsigned_absis nowconst fn.time::format_description::well_known::Iso8601now has a default. Thismeans
Iso8601is the same asIso8601::DEFAULT.Parsedstruct has been reduced in size from 56 to 32 bytes (a 43% reduction).v0.3.13Compare Source
Fixed
wasm-bindgenwork again.v0.3.12Compare Source
Added
js-sysnow supports obtaining the system's local UTC offset.Changed
Dateoperations has improved when using thelarge-datesfeature.OffsetDateTimenow stores the value in the attachedUtcOffset, notUTC. This leads to significant performance gains on nearly all
OffsetDateTimemethods.Fixed
Times can no longer panic. This previously occurred in some situations where theresult was invalid.
v0.3.11Compare Source
Fixed
serdeTimesubtracted fromTimecan panic. This was caused by a bug that has always existed,in that an internal invariant was not upheld. Memory safety was not violated.
v0.3.10Compare Source
Added
Duration::unsigned_abs, which returns astd::time::DurationDurationcan now be formatted with a.Nspecifier, providing a shorter representation whenusing
Display.nullasNoneon serde structsFixed
Rfc3339.Changed
Rfc2822has been improved.only serves to catch bugs and is disabled in release mode.
v0.3.9Added
time::serde::format_description!time::format_description!, but it generates a module that can be usedin
#[serde(with = "foo")]. This makes it far easier to serialize/deserialize a custom format.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 DurationDeprecated
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_secondChanged
TryFromParsed::ComponentRangeerrorvariant if the leap second could not occur at that given moment.
v0.3.8This release is broken and has been yanked.
v0.3.7Compare Source
Fixed
Solaris and Illumos build again.
v0.3.6Compare Source
Added
Date::saturating_addDate::saturating_subPrimitiveDateTime::saturating_addPrimitiveDateTime::saturating_subOffsetDateTime::saturating_addOffsetDateTime::saturating_subPrimitiveDatetime::MINPrimitiveDatetime::MAXRfc2822format descriptionserde-well-knownfeature flag.Changed
num_threadscrate.format fails to deserialize.
Fixed
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.