Compare commits

...

1 Commits

Author SHA1 Message Date
Rory Flynn 051b1cb6bc Use backwards-compatible datetime.timezone.utc 2024-04-19 16:54:26 +02:00
1 changed files with 4 additions and 7 deletions

View File

@ -59,13 +59,10 @@ def convert_datetime_to_iso(date_time: datetime.datetime) -> str:
:rtype: str
"""
try:
if date_time.tzinfo:
# Timezone aware object - convert to UTC
date_time = date_time.astimezone(tz=datetime.UTC)
return date_time.strftime("%Y-%m-%d %H:%M:%S.%f")
except Exception:
return ""
if date_time.tzinfo:
# Timezone aware object - convert to UTC
date_time = date_time.astimezone(tz=datetime.timezone.utc)
return date_time.strftime("%Y-%m-%d %H:%M:%S.%f")
def convert_unix_to_utc_datetime(