fix(convert_utc_to_timezone): set UTC if tzinfo undefined

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2024-12-10 16:12:01 +05:30
parent c4792204df
commit 4cf18d37bd
No known key found for this signature in database
GPG key ID: 9DCC61E211BF645F

View file

@ -372,7 +372,7 @@ def get_system_timezone() -> str:
def convert_utc_to_timezone(utc_timestamp: datetime.datetime, time_zone: str) -> datetime.datetime:
if utc_timestamp.tzinfo is None:
utc_timestamp = utc_timestamp.replace(tzinfo=ZoneInfo(time_zone))
utc_timestamp = utc_timestamp.replace(tzinfo=ZoneInfo("UTC"))
try:
return utc_timestamp.astimezone(ZoneInfo(time_zone))