diff --git a/utils.py b/utils.py index b7397649b..a74b807c3 100644 --- a/utils.py +++ b/utils.py @@ -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)