Skip to content

Commit 1795aff

Browse files
authored
Merge pull request #30 from FoamyGuy/timestamp_note
Note about timestamp() float precision.
2 parents 660cf0d + 285cdda commit 1795aff

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

adafruit_datetime.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1520,7 +1520,14 @@ def toordinal(self) -> int:
15201520
return _ymd2ord(self._year, self._month, self._day)
15211521

15221522
def timestamp(self) -> float:
1523-
"Return POSIX timestamp as float"
1523+
"""Return POSIX timestamp as float.
1524+
1525+
Note that Floats on most boards are encoded in 30 bits
1526+
internally, with effectively 22 bits of precision. As a result,
1527+
for modern dates this value can be off by several minutes.
1528+
As a workaround you can access the function ``_mktime()``
1529+
to get an int version of the timestamp.
1530+
"""
15241531
if not self._tzinfo is None:
15251532
return (self - _EPOCH).total_seconds()
15261533
s = self._mktime()

0 commit comments

Comments
 (0)