jbzreminder/utils.py

15 lines
358 B
Python
Raw Normal View History

2021-03-16 19:28:51 +01:00
from datetime import datetime
from pytz import timezone, utc
def time_remaining(target):
due = target - datetime.utcnow()
return int(due.total_seconds())
def to_ita_tz(utctime):
rome = timezone('Europe/Rome')
utc_dt = utctime.replace(tzinfo=utc)
rome_time = utc_dt.astimezone(rome)
return "{:%d-%m-%Y %H:%M %Z}".format(rome_time)