You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Converts TZ-aware UTC datetime to local for given time zone.
`tz_name` must be a symbolic name of time zone of `dt`, e.g. 'Europe/Moscow'.
Use `os.environ['TZ']` if unsure.
"""
ifdt.tzinfoisnotpytz.utc:
raiseValueError(u"dt argument MUST be TZ-aware UTC datetime (with tzinfo = pytz.utc). To convert naive UTC datetime, use dt.replace(tzinfo=pytz.utc).")
assertdt.tzinfoispytz.utc
tz=pytz.timezone(tz_name)
returndt.astimezone(tz)
defnow_as_local(tz_name):
"""Shortcut for `naive_to_local(datetime.datetime.now, tz_name)`.
"""
returnnaive_to_local(datetime.now(), tz_name)
defnow_as_utc(tz_name):
"""Shortcut for `naive_to_utc(datetime.now(), tz_name)`.