From b2ee818b986d7e9750c53f18f5879eec8e21ef1f Mon Sep 17 00:00:00 2001 From: foamyguy Date: Wed, 15 Jan 2025 11:54:34 -0600 Subject: [PATCH 1/3] note about timestamp() float precision. --- adafruit_datetime.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/adafruit_datetime.py b/adafruit_datetime.py index 99e30a4..52247f3 100755 --- a/adafruit_datetime.py +++ b/adafruit_datetime.py @@ -1520,7 +1520,14 @@ def toordinal(self) -> int: return _ymd2ord(self._year, self._month, self._day) def timestamp(self) -> float: - "Return POSIX timestamp as 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 ``_mitime()`` to get an int version of the timestamp. + """ if not self._tzinfo is None: return (self - _EPOCH).total_seconds() s = self._mktime() From bd7f6eb75888e67a918fc2d10e9c038751b88cca Mon Sep 17 00:00:00 2001 From: foamyguy Date: Wed, 15 Jan 2025 11:57:37 -0600 Subject: [PATCH 2/3] format docstring --- adafruit_datetime.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/adafruit_datetime.py b/adafruit_datetime.py index 52247f3..3919d36 100755 --- a/adafruit_datetime.py +++ b/adafruit_datetime.py @@ -1522,11 +1522,11 @@ def toordinal(self) -> int: 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 ``_mitime()`` to get an int version of the timestamp. + 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 ``_mitime()`` + to get an int version of the timestamp. """ if not self._tzinfo is None: return (self - _EPOCH).total_seconds() From 285cdda11b729cb591ceb89fb1bf073470cebe35 Mon Sep 17 00:00:00 2001 From: "Limor \"Ladyada\" Fried" Date: Thu, 16 Jan 2025 11:49:32 -0500 Subject: [PATCH 3/3] Update adafruit_datetime.py Co-authored-by: Neradoc --- adafruit_datetime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_datetime.py b/adafruit_datetime.py index 3919d36..83dceef 100755 --- a/adafruit_datetime.py +++ b/adafruit_datetime.py @@ -1525,7 +1525,7 @@ def timestamp(self) -> 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 ``_mitime()`` + As a workaround you can access the function ``_mktime()`` to get an int version of the timestamp. """ if not self._tzinfo is None: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy