summary refs log tree commit diff stats
path: root/lib/pure/times.nim
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pure/times.nim')
-rw-r--r--lib/pure/times.nim11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/pure/times.nim b/lib/pure/times.nim
index 6251c70d9..9f6ea5722 100644
--- a/lib/pure/times.nim
+++ b/lib/pure/times.nim
@@ -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: