Do not attempt to guess zero VTEC timestamps

This commit is contained in:
XANTRONIX Industrial 2025-02-21 16:30:47 -05:00
parent 8fb9f67a25
commit 9badc86e33

View file

@ -63,6 +63,8 @@ class VTECEventType(enum.StrEnum):
EXPERIMENTAL_VTEC = 'X' EXPERIMENTAL_VTEC = 'X'
class VTECBaseEvent(): class VTECBaseEvent():
__slots__ = 'timestamp_start', 'timestamp_end',
timestamp_start: datetime.datetime timestamp_start: datetime.datetime
timestamp_end: datetime.datetime timestamp_end: datetime.datetime
@ -71,20 +73,17 @@ class VTECBaseEvent():
self.timestamp_end = None self.timestamp_end = None
def parse_timestamps(self, text_start: str, text_end: str): def parse_timestamps(self, text_start: str, text_end: str):
start = parse_timestamp(text_start) if not is_timestamp_zero(text_start):
end = parse_timestamp(text_end) self.timestamp_start = parse_timestamp(text_start)
if is_timestamp_zero(text_start) and not is_timestamp_zero(text_end): if not is_timestamp_zero(text_end):
self.timestamp_start = end self.timestamp_end = parse_timestamp(text_end)
self.timestamp_end = end
elif not is_timestamp_zero(text_start) and is_timestamp_zero(text_end):
self.timestamp_start = start
self.timestamp_end = start
else:
self.timestamp_start = start
self.timestamp_end = end
class VTECEvent(VTECBaseEvent): class VTECEvent(VTECBaseEvent):
__slots__ = (
'typeof', 'actions', 'wfo', 'phenom', 'sig', 'etn'
)
typeof: str typeof: str
actions: str actions: str
wfo: str wfo: str
@ -92,9 +91,6 @@ class VTECEvent(VTECBaseEvent):
sig: str sig: str
etn: int etn: int
timestamp_start: datetime.datetime
timestamp_end: datetime.datetime
@staticmethod @staticmethod
def parse(text: str) -> Self: def parse(text: str) -> Self:
match = RE_PHENOM.match(text) match = RE_PHENOM.match(text)
@ -116,16 +112,13 @@ class VTECEvent(VTECBaseEvent):
class VTECHydroEvent(VTECBaseEvent): class VTECHydroEvent(VTECBaseEvent):
__slots__ = ( __slots__ = (
'severity', 'cause', 'record', 'timestamp_start', 'timestamp_end' 'severity', 'cause', 'record'
) )
severity: str severity: str
cause: str cause: str
record: str record: str
timestamp_start: datetime.datetime
timestamp_end: datetime.datetime
@staticmethod @staticmethod
def parse(text: str) -> Self: def parse(text: str) -> Self:
match = RE_HYDRO.match(text) match = RE_HYDRO.match(text)