Skip to content
Snippets Groups Projects
Commit 09fdb2ac authored by Jan David Mol's avatar Jan David Mol
Browse files

L2SS-244: Return a max datetime in case of parse issues, not a min datetime...

L2SS-244: Return a max datetime in case of parse issues, not a min datetime which also indicates zeroes
parent c9cecece
No related branches found
No related tags found
1 merge request!56L2SS-244: Expose the SSTs in MPs
......@@ -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. """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment