diff --git a/src/naive/time/mod.rs b/src/naive/time/mod.rs index 27fa9fe9b7..60cec8318a 100644 --- a/src/naive/time/mod.rs +++ b/src/naive/time/mod.rs @@ -1180,6 +1180,15 @@ impl AddAssign for NaiveTime { } } +impl Add for NaiveTime { + type Output = NaiveTime; + + #[inline] + fn add(self, rhs: FixedOffset) -> NaiveTime { + self.overflowing_add_offset(rhs).0 + } +} + /// A subtraction of `Duration` from `NaiveTime` wraps around and never overflows or underflows. /// In particular the addition ignores integral number of days. /// It is the same as the addition with a negated `Duration`. @@ -1262,6 +1271,15 @@ impl SubAssign for NaiveTime { } } +impl Sub for NaiveTime { + type Output = NaiveTime; + + #[inline] + fn sub(self, rhs: FixedOffset) -> NaiveTime { + self.overflowing_sub_offset(rhs).0 + } +} + /// Subtracts another `NaiveTime` from the current time. /// Returns a `Duration` within +/- 1 day. /// This does not overflow or underflow at all. diff --git a/src/offset/fixed.rs b/src/offset/fixed.rs index 57ceccbe6c..8038e1a5e5 100644 --- a/src/offset/fixed.rs +++ b/src/offset/fixed.rs @@ -13,7 +13,7 @@ use rkyv::{Archive, Deserialize, Serialize}; use super::{LocalResult, Offset, TimeZone}; use crate::duration::Duration as OldDuration; use crate::format::{scan, OUT_OF_RANGE}; -use crate::naive::{NaiveDate, NaiveDateTime, NaiveTime}; +use crate::naive::{NaiveDate, NaiveDateTime}; use crate::{DateTime, ParseError, Timelike}; /// The time zone with fixed offset, from UTC-23:59:59 to UTC+23:59:59. @@ -199,24 +199,6 @@ where (lhs + OldDuration::seconds(i64::from(rhs))).with_nanosecond(nanos).unwrap() } -impl Add for NaiveTime { - type Output = NaiveTime; - - #[inline] - fn add(self, rhs: FixedOffset) -> NaiveTime { - self.overflowing_add_offset(rhs).0 - } -} - -impl Sub for NaiveTime { - type Output = NaiveTime; - - #[inline] - fn sub(self, rhs: FixedOffset) -> NaiveTime { - self.overflowing_sub_offset(rhs).0 - } -} - impl Add for NaiveDateTime { type Output = NaiveDateTime;