Handle failure to get timezone

main
Bob Mottram 2025-05-27 15:54:15 +01:00
parent 24a6f3ca0d
commit 6e324b2cc7
1 changed files with 2 additions and 1 deletions

View File

@ -3799,13 +3799,14 @@ def valid_hash_tag(hashtag: str) -> bool:
def convert_published_to_local_timezone(published, timezone: str) -> str:
"""Converts a post published time into local time
"""
to_zone = None
from_zone = tz.gettz('UTC')
if timezone:
try:
to_zone = tz.gettz(timezone)
except BaseException:
pass
if not timezone:
if not timezone or not to_zone:
return published
utc = published.replace(tzinfo=from_zone)