File: //home/arjun/projects/buyercall/buyercall/blueprints/sysadmin/utilities/utc_to_timezone.py
from datetime import datetime
from pytz import timezone, utc
class FromUTC:
@staticmethod
def get_est_now():
# Get the current UTC time
utc_now = datetime.utcnow()
# Create a timezone object for EST
est_tz = timezone('US/Eastern')
# Convert the UTC time to EST
return utc_now.replace(tzinfo=utc).astimezone(est_tz)
@staticmethod
def get_timezone_now(tz: str):
# Get the current UTC time
utc_now = datetime.utcnow()
# Create a timezone object for tz
target_tz = timezone(tz)
# Convert the UTC time to tz
return utc_now.replace(tzinfo=utc).astimezone(target_tz)
@staticmethod
def get_est_custom_date(date_time):
# Create a timezone object for EST
est_tz = timezone('US/Eastern')
# Convert the UTC time to EST
return date_time.replace(tzinfo=utc).astimezone(est_tz)