diff --git a/adafruit_ntp.py b/adafruit_ntp.py index bc6db0d..5d71a72 100644 --- a/adafruit_ntp.py +++ b/adafruit_ntp.py @@ -102,6 +102,10 @@ def datetime(self) -> time.struct_time: self.next_sync = destination + cache_offset * 1_000_000_000 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 == 0: + raise ArithmeticError("ntp value is invalid (empty)") + self._monotonic_start = ( seconds + self._tz_offset