mirror of https://gitlab.com/bashrc2/epicyon
Handle failure to get timezone
parent
24a6f3ca0d
commit
6e324b2cc7
3
utils.py
3
utils.py
|
@ -3799,13 +3799,14 @@ def valid_hash_tag(hashtag: str) -> bool:
|
||||||
def convert_published_to_local_timezone(published, timezone: str) -> str:
|
def convert_published_to_local_timezone(published, timezone: str) -> str:
|
||||||
"""Converts a post published time into local time
|
"""Converts a post published time into local time
|
||||||
"""
|
"""
|
||||||
|
to_zone = None
|
||||||
from_zone = tz.gettz('UTC')
|
from_zone = tz.gettz('UTC')
|
||||||
if timezone:
|
if timezone:
|
||||||
try:
|
try:
|
||||||
to_zone = tz.gettz(timezone)
|
to_zone = tz.gettz(timezone)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
if not timezone:
|
if not timezone or not to_zone:
|
||||||
return published
|
return published
|
||||||
|
|
||||||
utc = published.replace(tzinfo=from_zone)
|
utc = published.replace(tzinfo=from_zone)
|
||||||
|
|
Loading…
Reference in New Issue