mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-12 22:33:49 +00:00
Don't assume utcOffset == +0 for old dates on Windows (#8744)
This commit is contained in:
committed by
Andreas Rumpf
parent
7532b37405
commit
42333d27d0
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user