Skip to content

Commit b2ee818

Browse files
committed
note about timestamp() float precision.
1 parent c024272 commit b2ee818

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

adafruit_datetime.py

Lines changed: 8 additions & 1 deletion
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
1526+
boards are encoded in 30 bits internally, with effectively 22
1527+
bits of precision. As a result, for modern dates this value
1528+
can be off by several minutes. As a workaround you can access
1529+
the function ``_mitime()`` 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)