Fixed a bug that the leap second can be mapped wrongly in the local tz.

Turns out to be a relic of pre-FixedOffset offset calculation code. Only
manifests itself when the local time zone is behind UTC.

Fixes #128.
This commit is contained in:
Kang Seonghoon 2017-02-14 03:07:06 +09:00
parent db9b98f691
commit 73a3ec5514
No known key found for this signature in database
GPG Key ID: 82440FABA6709020
1 changed files with 1 additions and 2 deletions

View File

@ -4,7 +4,6 @@
//! The local (system) time zone.
use oldtime;
use oldtime::Duration as OldDuration;
use {Datelike, Timelike};
use naive::date::NaiveDate;
@ -39,7 +38,7 @@ fn tm_to_datetime(mut tm: oldtime::Tm) -> DateTime<Local> {
let time = NaiveTime::from_hms_nano(tm.tm_hour as u32, tm.tm_min as u32,
tm.tm_sec as u32, tm.tm_nsec as u32);
let offset = FixedOffset::east(tm.tm_utcoff);
DateTime::from_utc(date.and_time(time) + OldDuration::seconds(-tm.tm_utcoff as i64), offset)
DateTime::from_utc(date.and_time(time) - offset, offset)
}
/// Converts a local `NaiveDateTime` to the `time::Timespec`.