Don't assume utcOffset == +0 for old dates on Windows (#8744)

This commit is contained in:
Oscar Nihlgård
2018-08-23 17:55:53 +02:00
committed by Andreas Rumpf
parent 7532b37405
commit 42333d27d0

View File

@@ -957,6 +957,17 @@ else:
result.inc tm.second
proc getLocalOffsetAndDst(unix: int64): tuple[offset: int, dst: bool] =
# Windows can't handle unix < 0, so we fall back to unix = 0.
# FIXME: This should be improved by falling back to the WinAPI instead.
when defined(windows):
if unix < 0:
var a = 0.CTime
let tmPtr = localtime(addr(a))
if not tmPtr.isNil:
let tm = tmPtr[]
return ((0 - tm.toAdjUnix).int, false)
return (0, false)
var a = unix.CTime
let tmPtr = localtime(addr(a))
if not tmPtr.isNil: