From 45c251cb1d5da8e1becfc64b616569290594b1b4 Mon Sep 17 00:00:00 2001 From: Simon Krauter Date: Fri, 6 Jan 2017 23:29:20 +0100 Subject: fixes 4804 toTime(): Use the Windows-specific part for every OS, because it gives correct results on Linux too. The removed code for Linux gives wrong results. --- lib/pure/times.nim | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'lib/pure') diff --git a/lib/pure/times.nim b/lib/pure/times.nim index 39d46c675..82fc9ad41 100644 --- a/lib/pure/times.nim +++ b/lib/pure/times.nim @@ -523,16 +523,10 @@ when not defined(JS): var cTimeInfo = timeInfo # for C++ we have to make a copy # because the header of mktime is broken in my version of libc - when defined(windows): - # On Windows `mktime` is broken enough to make this work. - result = mktime(timeInfoToTM(cTimeInfo)) - # mktime is defined to interpret the input as local time. As timeInfoToTM - # does ignore the timezone, we need to adjust this here. - result = Time(TimeImpl(result) - getTimezone() + timeInfo.timezone) - else: - result = timegm(timeInfoToTM(cTimeInfo)) - # As timeInfoToTM does ignore the timezone, we need to adjust this here. - result = Time(TimeImpl(result) + timeInfo.timezone) + result = mktime(timeInfoToTM(cTimeInfo)) + # mktime is defined to interpret the input as local time. As timeInfoToTM + # does ignore the timezone, we need to adjust this here. + result = Time(TimeImpl(result) - getTimezone() + timeInfo.timezone) proc timeInfoToTime(timeInfo: TimeInfo): Time = toTime(timeInfo) -- cgit 1.4.1-2-gfad0