Skip to content

Commit

Permalink
Use backwards-compatible datetime.timezone.utc (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
roaree authored Apr 19, 2024
1 parent 59e6dff commit 0509eaa
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions mvt/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 0509eaa

Please sign in to comment.