Fix VTEC timestamp parsing
This commit is contained in:
parent
0de6a89408
commit
04c5692df1
1 changed files with 26 additions and 3 deletions
|
@ -26,9 +26,32 @@ RE_HYDRO = re.compile(r'''
|
||||||
''', re.X)
|
''', re.X)
|
||||||
|
|
||||||
def parse_timestamp(text: str):
|
def parse_timestamp(text: str):
|
||||||
return datetime.datetime.strptime(
|
year = int(text[0:2])
|
||||||
text, '%y%m%dT%H%M%SZ'
|
month = int(text[2:4])
|
||||||
).astimezone(datetime.UTC)
|
day = int(text[4:6])
|
||||||
|
hour = int(text[7:9])
|
||||||
|
minute = int(text[9:11])
|
||||||
|
|
||||||
|
if year >= 70:
|
||||||
|
year += 1900
|
||||||
|
else:
|
||||||
|
year += 2000
|
||||||
|
|
||||||
|
if month == 0:
|
||||||
|
month = 1
|
||||||
|
|
||||||
|
if day == 0:
|
||||||
|
day = 1
|
||||||
|
|
||||||
|
return datetime.datetime(
|
||||||
|
year = year,
|
||||||
|
month = month,
|
||||||
|
day = day,
|
||||||
|
hour = hour,
|
||||||
|
minute = minute,
|
||||||
|
second = 0,
|
||||||
|
tzinfo = datetime.UTC
|
||||||
|
)
|
||||||
|
|
||||||
class VTECEventType(enum.StrEnum):
|
class VTECEventType(enum.StrEnum):
|
||||||
OPERATIONAL = 'O'
|
OPERATIONAL = 'O'
|
||||||
|
|
Loading…
Add table
Reference in a new issue