[3.6] bpo-29097: Forego fold detection on windows for low timestamp v… · python/cpython@6ea8a3a (original) (raw)
`@@ -6,6 +6,7 @@
`
6
6
``
7
7
`import time as _time
`
8
8
`import math as _math
`
``
9
`+
import sys
`
9
10
``
10
11
`def _cmp(x, y):
`
11
12
`return 0 if x == y else 1 if x > y else -1
`
`@@ -1444,6 +1445,14 @@ def _fromtimestamp(cls, t, utc, tz):
`
1444
1445
`# 23 hours at 1969-09-30 13:00:00 in Kwajalein.
`
1445
1446
`# Let's probe 24 hours in the past to detect a transition:
`
1446
1447
`max_fold_seconds = 24 * 3600
`
``
1448
+
``
1449
`+
On Windows localtime_s throws an OSError for negative values,
`
``
1450
`+
thus we can't perform fold detection for values of time less
`
``
1451
`+
than the max time fold. See comments in _datetimemodule's
`
``
1452
`+
version of this method for more details.
`
``
1453
`+
if t < max_fold_seconds and sys.platform.startswith("win"):
`
``
1454
`+
return result
`
``
1455
+
1447
1456
`y, m, d, hh, mm, ss = converter(t - max_fold_seconds)[:6]
`
1448
1457
`probe1 = cls(y, m, d, hh, mm, ss, us, tz)
`
1449
1458
`trans = result - probe1 - timedelta(0, max_fold_seconds)
`