diff options
author | Simon Krauter <trustable-code@users.noreply.github.com> | 2017-01-06 23:29:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-06 23:29:20 +0100 |
commit | 45c251cb1d5da8e1becfc64b616569290594b1b4 (patch) | |
tree | b21c843688b1fe5692dd233eec096fee8ff82b4a /lib | |
parent | 92b48dbcad8fc564a2146a5c4fa73aba3dbc99d1 (diff) | |
download | Nim-45c251cb1d5da8e1becfc64b616569290594b1b4.tar.gz |
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/times.nim | 14 |
1 files changed, 4 insertions, 10 deletions
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) |