Merge pull request #337 from chronotope/fix-addition-with-timezones

Adjust timezones after doing Duration addition
This commit is contained in:
Brandon W Maister 2019-09-03 08:08:32 -04:00 committed by GitHub
commit b1337fc123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -202,7 +202,8 @@ impl<Tz: TimeZone> DateTime<Tz> {
#[inline]
pub fn checked_add_signed(self, rhs: OldDuration) -> Option<DateTime<Tz>> {
let datetime = try_opt!(self.datetime.checked_add_signed(rhs));
Some(DateTime { datetime: datetime, offset: self.offset })
let tz = self.timezone();
Some(tz.from_utc_datetime(&datetime))
}
/// Subtracts given `Duration` from the current date and time.
@ -211,7 +212,8 @@ impl<Tz: TimeZone> DateTime<Tz> {
#[inline]
pub fn checked_sub_signed(self, rhs: OldDuration) -> Option<DateTime<Tz>> {
let datetime = try_opt!(self.datetime.checked_sub_signed(rhs));
Some(DateTime { datetime: datetime, offset: self.offset })
let tz = self.timezone();
Some(tz.from_utc_datetime(&datetime))
}
/// Subtracts another `DateTime` from the current date and time.