I have a list of users:
tom, 0530, eastern
dick, 0745, pacific
harry, 0915, central
ect...
I need to send them an email at that specific time (or within 5 minutes) for their timezone. I've been working on a python script that I would run with cron every 5 minutes.
## pseudo code:
for user in users:
if difference of usertime and utctime is <= 5 minutes:
send email
I'm getting close, but doing the math with the converted timezones is where I'm stuck now.
code:
import datetime
import pytz
today = datetime.datetime.now().date()
user1 = pytz.timezone('US/Eastern').localize(datetime.datetime(today.year, today.month, today.day, 5, 30))
now_utc = datetime.datetime.now(pytz.timezone('UTC'))
user1_converted = user1.astimezone(pytz.timezone('UTC'))
now_utc - user1_converted
##maths