Skip to content

Commit deee5c4

Browse files
committed
doc: clarify the guaranteeds for Zoned::{since,until}
Specifically, that you can't get any units bigger than hours *by default*. We also fix what was probably a copy-and-paste error in the `Sub` trait implementation docs for `Zoned`. (I probably copied it from `jiff::civil::DateTime`, where it can return days by default.) And we apply similar clarifications to the `jiff::civil::DateTime` docs as well. Ref microsoft/openvmm#1028 (comment)
1 parent 4404fb0 commit deee5c4

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/civil/datetime.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1868,6 +1868,9 @@ impl DateTime {
18681868
/// Depending on the input provided, the span returned is rounded. It may
18691869
/// also be balanced up to bigger units than the default. By default, the
18701870
/// span returned is balanced such that the biggest possible unit is days.
1871+
/// This default is an API guarantee. Users can rely on the default not
1872+
/// returning any calendar units bigger than days in the default
1873+
/// configuration.
18711874
///
18721875
/// This operation is configured by providing a [`DateTimeDifference`]
18731876
/// value. Since this routine accepts anything that implements
@@ -2647,7 +2650,8 @@ impl core::ops::SubAssign<Span> for DateTime {
26472650
///
26482651
/// Since this uses the default configuration for calculating a span between
26492652
/// two datetimes (no rounding and largest units is days), this will never
2650-
/// panic or fail in any way.
2653+
/// panic or fail in any way. It is guaranteed that the largest non-zero
2654+
/// unit in the `Span` returned will be days.
26512655
///
26522656
/// To configure the largest unit or enable rounding, use [`DateTime::since`].
26532657
///

src/zoned.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,6 +2391,8 @@ impl Zoned {
23912391
/// Depending on the input provided, the span returned is rounded. It may
23922392
/// also be balanced up to bigger units than the default. By default, the
23932393
/// span returned is balanced such that the biggest possible unit is hours.
2394+
/// This default is an API guarantee. Users can rely on the default not
2395+
/// returning any calendar units in the default configuration.
23942396
///
23952397
/// This operation is configured by providing a [`ZonedDifference`]
23962398
/// value. Since this routine accepts anything that implements
@@ -3331,8 +3333,9 @@ impl core::ops::SubAssign<Span> for Zoned {
33313333
/// is greater.
33323334
///
33333335
/// Since this uses the default configuration for calculating a span between
3334-
/// two zoned datetimes (no rounding and largest units is days), this will
3335-
/// never panic or fail in any way.
3336+
/// two zoned datetimes (no rounding and largest units is hours), this will
3337+
/// never panic or fail in any way. It is guaranteed that the largest non-zero
3338+
/// unit in the `Span` returned will be hours.
33363339
///
33373340
/// To configure the largest unit or enable rounding, use [`Zoned::since`].
33383341
impl<'a> core::ops::Sub for &'a Zoned {

0 commit comments

Comments
 (0)