From 09fdb2acc952478c820c4d9e7883202b53a55242 Mon Sep 17 00:00:00 2001 From: Jan David Mol <mol@astron.nl> Date: Tue, 15 Jun 2021 10:35:26 +0200 Subject: [PATCH] L2SS-244: Return a max datetime in case of parse issues, not a min datetime which also indicates zeroes --- devices/clients/SDP_statistics.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/devices/clients/SDP_statistics.py b/devices/clients/SDP_statistics.py index f8baff46c..b8417ef58 100644 --- a/devices/clients/SDP_statistics.py +++ b/devices/clients/SDP_statistics.py @@ -212,13 +212,16 @@ class StatisticsPacket(object): return unpack("<Q",self.packet[24:32])[0] def timestamp(self) -> datetime: - """ Returns the timestamp of the data in this packet. """ + """ Returns the timestamp of the data in this packet. + + Returns datetime.min if the block_serial_number in the packet is not set (0), + Returns datetime.max if the timestamp cannot be represented in python (likely because it is too large). """ try: return datetime.fromtimestamp(self.block_serial_number * self.block_period(), timezone.utc) except ValueError: # Let's not barf anytime we want to print a header - return datetime.fromtimestamp(0, timezone.utc) + return datetime.max def header(self) -> dict: """ Return all the header fields as a dict. """ -- GitLab