From a923944b8b56f448c03f9567deb75bc272361421 Mon Sep 17 00:00:00 2001 From: ted Date: Mon, 22 Jul 2024 19:57:10 -0700 Subject: [PATCH] PR feedback, test zero --- adafruit_ntp.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/adafruit_ntp.py b/adafruit_ntp.py index d1b29af..5d71a72 100644 --- a/adafruit_ntp.py +++ b/adafruit_ntp.py @@ -103,13 +103,8 @@ def datetime(self) -> time.struct_time: seconds = struct.unpack_from("!I", self._packet, offset=PACKET_SIZE - 8)[0] # value should always be larger; giving a small buffer to handle jitter. - if (seconds + 5) < self._monotonic_start: - failed_offset = (self._monotonic_start - seconds) / 1_000_000_000 - raise ArithmeticError( - "need a time machine, ntp time is " - + str(failed_offset) - + "seconds in the past." - ) + if seconds == 0: + raise ArithmeticError("ntp value is invalid (empty)") self._monotonic_start = ( seconds