Merge pull request #4 from adafruit/jepler-patch-1

datetime: fix _fromtimestamp for small-range floats
This commit is contained in:
Jeff Epler 2021-03-03 17:14:18 -06:00 committed by GitHub
commit 25f8de0a78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1283,7 +1283,10 @@ class datetime(date):
"""Construct a datetime from a POSIX timestamp (like time.time()).
A timezone info object may be passed in as well.
"""
frac, t = _math.modf(t)
if isinstance(t, float):
frac, t = _math.modf(t)
else:
frac = 0
us = round(frac * 1e6)
if us >= 1000000:
t += 1