diff --git a/src/tz/offset.rs b/src/tz/offset.rs index 1817b42..3cd44cd 100644 --- a/src/tz/offset.rs +++ b/src/tz/offset.rs @@ -453,67 +453,6 @@ impl Offset { .checked_sub_seconds(i64::from(self.seconds())) } - /// Returns the span of time from this offset until the other given. - /// - /// When the `other` offset is more west (i.e., more negative) of the prime - /// meridian than this offset, then the span returned will be negative. - /// - /// # Properties - /// - /// Adding the span returned to this offset will always equal the `other` - /// offset given. - /// - /// # Examples - /// - /// ``` - /// use jiff::{tz, ToSpan}; - /// - /// assert_eq!( - /// tz::offset(-5).until(tz::Offset::UTC), - /// (5 * 60 * 60).seconds(), - /// ); - /// // Flipping the operands in this case results in a negative span. - /// assert_eq!( - /// tz::Offset::UTC.until(tz::offset(-5)), - /// -(5 * 60 * 60).seconds(), - /// ); - /// ``` - #[inline] - pub fn until(self, other: Offset) -> Span { - Span::new() - .seconds_ranged(other.seconds_ranged() - self.seconds_ranged()) - } - - /// Returns the span of time since the other offset given from this offset. - /// - /// When the `other` is more east (i.e., more positive) of the prime - /// meridian than this offset, then the span returned will be negative. - /// - /// # Properties - /// - /// Adding the span returned to the `other` offset will always equal this - /// offset. - /// - /// # Examples - /// - /// ``` - /// use jiff::{tz, ToSpan}; - /// - /// assert_eq!( - /// tz::Offset::UTC.since(tz::offset(-5)), - /// (5 * 60 * 60).seconds(), - /// ); - /// // Flipping the operands in this case results in a negative span. - /// assert_eq!( - /// tz::offset(-5).since(tz::Offset::UTC), - /// -(5 * 60 * 60).seconds(), - /// ); - /// ``` - #[inline] - pub fn since(self, other: Offset) -> Span { - self.until(other).negate() - } - /// Adds the given span of time to this offset. /// /// Since time zone offsets have second resolution, any fractional seconds @@ -679,6 +618,67 @@ impl Offset { self.saturating_add(span.negate()) } + /// Returns the span of time from this offset until the other given. + /// + /// When the `other` offset is more west (i.e., more negative) of the prime + /// meridian than this offset, then the span returned will be negative. + /// + /// # Properties + /// + /// Adding the span returned to this offset will always equal the `other` + /// offset given. + /// + /// # Examples + /// + /// ``` + /// use jiff::{tz, ToSpan}; + /// + /// assert_eq!( + /// tz::offset(-5).until(tz::Offset::UTC), + /// (5 * 60 * 60).seconds(), + /// ); + /// // Flipping the operands in this case results in a negative span. + /// assert_eq!( + /// tz::Offset::UTC.until(tz::offset(-5)), + /// -(5 * 60 * 60).seconds(), + /// ); + /// ``` + #[inline] + pub fn until(self, other: Offset) -> Span { + Span::new() + .seconds_ranged(other.seconds_ranged() - self.seconds_ranged()) + } + + /// Returns the span of time since the other offset given from this offset. + /// + /// When the `other` is more east (i.e., more positive) of the prime + /// meridian than this offset, then the span returned will be negative. + /// + /// # Properties + /// + /// Adding the span returned to the `other` offset will always equal this + /// offset. + /// + /// # Examples + /// + /// ``` + /// use jiff::{tz, ToSpan}; + /// + /// assert_eq!( + /// tz::Offset::UTC.since(tz::offset(-5)), + /// (5 * 60 * 60).seconds(), + /// ); + /// // Flipping the operands in this case results in a negative span. + /// assert_eq!( + /// tz::offset(-5).since(tz::Offset::UTC), + /// -(5 * 60 * 60).seconds(), + /// ); + /// ``` + #[inline] + pub fn since(self, other: Offset) -> Span { + self.until(other).negate() + } + /// Returns this offset as a [`Span`]. #[inline] pub(crate) fn to_span(self) -> Span {