diff --git a/adafruit_datetime.py b/adafruit_datetime.py index 83dceef..216ef5d 100755 --- a/adafruit_datetime.py +++ b/adafruit_datetime.py @@ -1520,18 +1520,10 @@ def toordinal(self) -> int: return _ymd2ord(self._year, self._month, self._day) def timestamp(self) -> float: - """Return POSIX timestamp as float. - - Note that Floats on most boards are encoded in 30 bits - internally, with effectively 22 bits of precision. As a result, - for modern dates this value can be off by several minutes. - As a workaround you can access the function ``_mktime()`` - to get an int version of the timestamp. - """ + """Return POSIX timestamp as int, similar to the value returned by ``time.time()``.""" if not self._tzinfo is None: return (self - _EPOCH).total_seconds() - s = self._mktime() - return s + self.microsecond / 1e6 + return self._mktime() def weekday(self) -> int: """Return the day of the week as an integer, where Monday is 0 and Sunday is 6.""" diff --git a/tests/test_datetime.py b/tests/test_datetime.py index 6c4d5f1..bab3b64 100644 --- a/tests/test_datetime.py +++ b/tests/test_datetime.py @@ -527,8 +527,8 @@ def test_utcfromtimestamp(self): def test_timestamp_naive(self): t = self.theclass(1970, 1, 1) self.assertEqual(t.timestamp(), 18000.0) - t = self.theclass(1970, 1, 1, 1, 2, 3, 4) - self.assertEqual(t.timestamp(), 18000.0 + 3600 + 2 * 60 + 3 + 4 * 1e-6) + t = self.theclass(1970, 1, 1, 1, 2, 3) + self.assertEqual(t.timestamp(), 18000.0 + 3600 + 2 * 60 + 3) # Missing hour t0 = self.theclass(2012, 3, 11, 2, 30) t1 = t0.replace(fold=1)