File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1166,22 +1166,13 @@ impl<Tz: TimeZone> AddAssign<Duration> for DateTime<Tz> {
11661166 }
11671167}
11681168
1169- fn add_with_leapsecond < T > ( lhs : & T , rhs : i32 ) -> T
1170- where
1171- T : Timelike + Add < OldDuration , Output = T > ,
1172- {
1173- // extract and temporarily remove the fractional part and later recover it
1174- let nanos = lhs. nanosecond ( ) ;
1175- let lhs = lhs. with_nanosecond ( 0 ) . unwrap ( ) ;
1176- ( lhs + OldDuration :: seconds ( i64:: from ( rhs) ) ) . with_nanosecond ( nanos) . unwrap ( )
1177- }
1178-
11791169impl < Tz : TimeZone > Add < FixedOffset > for DateTime < Tz > {
11801170 type Output = DateTime < Tz > ;
11811171
11821172 #[ inline]
1183- fn add ( self , rhs : FixedOffset ) -> DateTime < Tz > {
1184- add_with_leapsecond ( & self , rhs. local_minus_utc ( ) )
1173+ fn add ( mut self , rhs : FixedOffset ) -> DateTime < Tz > {
1174+ self . datetime = self . naive_utc ( ) . checked_add_offset ( rhs) . unwrap ( ) ;
1175+ self
11851176 }
11861177}
11871178
@@ -1236,8 +1227,9 @@ impl<Tz: TimeZone> Sub<FixedOffset> for DateTime<Tz> {
12361227 type Output = DateTime < Tz > ;
12371228
12381229 #[ inline]
1239- fn sub ( self , rhs : FixedOffset ) -> DateTime < Tz > {
1240- add_with_leapsecond ( & self , -rhs. local_minus_utc ( ) )
1230+ fn sub ( mut self , rhs : FixedOffset ) -> DateTime < Tz > {
1231+ self . datetime = self . naive_utc ( ) . checked_sub_offset ( rhs) . unwrap ( ) ;
1232+ self
12411233 }
12421234}
12431235
You can’t perform that action at this time.
0 commit comments