From 73a3ec5514ff615fcc609bc373104abf8bb35c9c Mon Sep 17 00:00:00 2001 From: Kang Seonghoon Date: Tue, 14 Feb 2017 03:07:06 +0900 Subject: [PATCH] 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. --- src/offset/local.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/offset/local.rs b/src/offset/local.rs index dd037f8..800f1c9 100644 --- a/src/offset/local.rs +++ b/src/offset/local.rs @@ -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 { 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`.