Do not attempt to guess zero VTEC timestamps
This commit is contained in:
parent
8fb9f67a25
commit
9badc86e33
1 changed files with 11 additions and 18 deletions
|
@ -63,6 +63,8 @@ class VTECEventType(enum.StrEnum):
|
|||
EXPERIMENTAL_VTEC = 'X'
|
||||
|
||||
class VTECBaseEvent():
|
||||
__slots__ = 'timestamp_start', 'timestamp_end',
|
||||
|
||||
timestamp_start: datetime.datetime
|
||||
timestamp_end: datetime.datetime
|
||||
|
||||
|
@ -71,20 +73,17 @@ class VTECBaseEvent():
|
|||
self.timestamp_end = None
|
||||
|
||||
def parse_timestamps(self, text_start: str, text_end: str):
|
||||
start = parse_timestamp(text_start)
|
||||
end = parse_timestamp(text_end)
|
||||
if not is_timestamp_zero(text_start):
|
||||
self.timestamp_start = parse_timestamp(text_start)
|
||||
|
||||
if is_timestamp_zero(text_start) and not is_timestamp_zero(text_end):
|
||||
self.timestamp_start = 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
|
||||
if not is_timestamp_zero(text_end):
|
||||
self.timestamp_end = parse_timestamp(text_end)
|
||||
|
||||
class VTECEvent(VTECBaseEvent):
|
||||
__slots__ = (
|
||||
'typeof', 'actions', 'wfo', 'phenom', 'sig', 'etn'
|
||||
)
|
||||
|
||||
typeof: str
|
||||
actions: str
|
||||
wfo: str
|
||||
|
@ -92,9 +91,6 @@ class VTECEvent(VTECBaseEvent):
|
|||
sig: str
|
||||
etn: int
|
||||
|
||||
timestamp_start: datetime.datetime
|
||||
timestamp_end: datetime.datetime
|
||||
|
||||
@staticmethod
|
||||
def parse(text: str) -> Self:
|
||||
match = RE_PHENOM.match(text)
|
||||
|
@ -116,16 +112,13 @@ class VTECEvent(VTECBaseEvent):
|
|||
|
||||
class VTECHydroEvent(VTECBaseEvent):
|
||||
__slots__ = (
|
||||
'severity', 'cause', 'record', 'timestamp_start', 'timestamp_end'
|
||||
'severity', 'cause', 'record'
|
||||
)
|
||||
|
||||
severity: str
|
||||
cause: str
|
||||
record: str
|
||||
|
||||
timestamp_start: datetime.datetime
|
||||
timestamp_end: datetime.datetime
|
||||
|
||||
@staticmethod
|
||||
def parse(text: str) -> Self:
|
||||
match = RE_HYDRO.match(text)
|
||||
|
|
Loading…
Add table
Reference in a new issue