fix date formatting

This commit is contained in:
Wolfgang Hottgenroth 2025-03-11 10:33:24 +01:00
parent 57c04685a1
commit c0dfb9b628

View File

@ -1,4 +1,5 @@
import ntp.packet import ntp.packet
import ntp.ntpc
import threading import threading
from contextlib import AbstractContextManager from contextlib import AbstractContextManager
import time import time
@ -40,14 +41,7 @@ def pass_value(x):
return x return x
def string_ntp_seconds(x): def string_ntp_seconds(x):
h1, h2 = x.split('.') return ntp.ntpc.prettydate(x).split(' ')[1]
seconds = int(h1, 16)
fraction = int(h2, 16)
ntp_epoch = datetime.datetime(1900, 1, 1)
timestamp = ntp_epoch + datetime.timedelta(seconds=seconds)
microseconds = fraction // 1000
timestamp = timestamp.replace(microsecond=microseconds)
return f"{timestamp} UTC"
SYSINFO_KEYS = [ SYSINFO_KEYS = [