18 lines
383 B
Python
18 lines
383 B
Python
"""
|
|
Wrapper around date/time parsing
|
|
"""
|
|
|
|
import datetime
|
|
from dateutil.parser import parse
|
|
|
|
|
|
def parse_datetime_to_utc(string) -> datetime.datetime:
|
|
parsed = parse(string)
|
|
|
|
if parsed.tzinfo is None:
|
|
# Convert to timezone aware datetime with the system's timezone
|
|
converted = parsed.astimezone()
|
|
else:
|
|
converted = parsed
|
|
|
|
return converted.astimezone(datetime.timezone.utc)
|