Sourced from time's changelog.
0.3.42 [2025-08-31]
Added
Time::duration_until
Time::duration_since
per_t
method for all types intime::convert
. This is similar to the existingper
method, but can return any of the primitive numeric types that can represent the result. This will cut down onas
casts while ensuring correctness. Type inference isn't perfect, so you may need to provide a type annotation in some situations.impl PartialOrd for Month
andimpl Ord for Month
; this assumes the months are in the same yearSystemTimeExt
trait, adding methods for checked arithmetic withtime::Duration
and obtaining the difference between twoSystemTime
s as atime::Duration
- Permit using
UtcDateTime
withrand
(this was inadvertently omitted previously)impl core::error::Error
for all error types (now available when thestd
feature 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
itoa
has 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_offset
andUtcDateTime::to_offset
has 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]
.
ed2852e
v0.3.42 release1067543
Fix copied commentf45bff5
Use const
block for readabilityb38c118
Add #[inline]
to most methodsf410951
Add #[track_caller]
to numerous methodsd30f3d0
Optimize Time::sub
e807ad3
Add tests, benchmarks3fcb83d
Optimize OffsetDateTime
comparisons95db5c3
Optimize UTC offset conversions998b26f
Optimize Time::duration_until