hive_sales_sync_costarica/utils/timezone.py
Marvin Vallecillo a2663d15be First commit
2024-07-17 04:19:28 -06:00

38 lines
575 B
Python

try:
# noinspection PyUnresolvedReferences
import pytz
def tz(tz_str):
return pytz.timezone(tz_str)
except ImportError:
import zoneinfo
def tz(tz_str):
return zoneinfo.ZoneInfo(tz_str)
from datetime import datetime, timezone
class Current:
value = timezone.utc
_current = Current()
def set_current(tz_str):
_current.value = tz(tz_str)
pass
def get_current():
return _current.value
def now():
return _current.value.localize(datetime.now())
def make_aware(value):
return _current.value.localize(value)