We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fc0f07c commit 1c4456bCopy full SHA for 1c4456b
adafruit_ntp.py
@@ -94,6 +94,16 @@ def datetime(self) -> time.struct_time:
94
poll = struct.unpack_from("!B", self._packet, offset=2)[0]
95
self.next_sync = destination + (2**poll) * 1_000_000_000
96
seconds = struct.unpack_from("!I", self._packet, offset=PACKET_SIZE - 8)[0]
97
+
98
+ # value should always be larger; giving a small buffer to handle jitter.
99
+ if (seconds + 5) < self._monotonic_start:
100
+ failed_offset = (self._monotonic_start - seconds) / 1_000_000_000
101
+ raise ArithmeticError(
102
+ "need a time machine, ntp time is "
103
+ + str(failed_offset)
104
+ + "seconds in the past."
105
+ )
106
107
self._monotonic_start = (
108
seconds
109
+ self._tz_offset
0 commit comments