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)
|
||||
|
||||
def parse_timestamp(text: str):
|
||||
return datetime.datetime.strptime(
|
||||
text, '%y%m%dT%H%M%SZ'
|
||||
).astimezone(datetime.UTC)
|
||||
year = int(text[0:2])
|
||||
month = int(text[2:4])
|
||||
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):
|
||||
OPERATIONAL = 'O'
|
||||
|
|
Loading…
Add table
Reference in a new issue