Skip to content

Commit 25f8de0

Browse files
authored
Merge pull request #4 from adafruit/jepler-patch-1
datetime: fix _fromtimestamp for small-range floats
2 parents 99f35da + f487c26 commit 25f8de0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

adafruit_datetime.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,10 @@ def _fromtimestamp(cls, t, utc, tz):
12831283
"""Construct a datetime from a POSIX timestamp (like time.time()).
12841284
A timezone info object may be passed in as well.
12851285
"""
1286-
frac, t = _math.modf(t)
1286+
if isinstance(t, float):
1287+
frac, t = _math.modf(t)
1288+
else:
1289+
frac = 0
12871290
us = round(frac * 1e6)
12881291
if us >= 1000000:
12891292
t += 1

0 commit comments

Comments
 (0)