I am trying to create some simple code that given a datetime, it would tell me if I would miss the train or not, based on the time (hour/minute) of a train timetable stored in the EDT time.
For example the time one of the entries in the timetabe is 1000 (got that time in June).
Now for example if I put my time to be t1 = datetime(2022,7,1,9,30, tzinfo=pytz('America/New York')),
function would return true (I should be able to catch the train since I get to the train station at 9:30am).
And if I input the time as t2=datetime(2022,12,15,9,30, tzinfo = pytz('America/New York'))
, it should return false for me since now the train is leaving at 0900 in New York time in December (but I do not want to manage all the messy conversion in my code).
One way I can think of is to look at the utcoffset()
of the times in June and then add that to the UTC date in December to do that comparison, but I am not sure if there is something that's even simpler and do not need to involve conversion to UTC.