I'm trying to convert datestrings to datetimes, but cannot find any reliable documentation involving which timezone codes map to which timezones, in particular I am dealing with timezones that utilize daylight savings time.
I have 4 potential timezone codes, and I am trying to determine what to pass to tz.gettz for the daylight savings ones.
import dateutil.parser as p
import dateutil.tz as tz
tzinfos = {"CST": tz.gettz("America/Chicago"),
"CDT": tz.gettz("?"), # HERE
"EST": tz.gettz("America/Eastern"),
"EDT": tz.gettz("?") # HERE
}
date_strings = ["Wed Mar 03 09:44:59 CST 2021",
"Wed Mar 03 09:44:59 CDT 2021",
"Wed Mar 03 09:44:59 EST 2021",
"Wed Mar 03 09:44:59 EDT 2021"]
for s in date_strings:
print(p.parse(s, tzinfos=tzinfos))
The datestrings are coming in via an API provided by my states department of transportation which gets the data from sensors built into the state highways, and the end-goal is to convert them all to UTC time, but I have no way of knowing what their UTC times should be, so I can't just guess the timezones and then verify them.
I've been going through this wikipedia page of timezones
and it appears as if CDT for example, would be the same as CST, being tz.gettz("America/Chicago") but the application I am dealing with will be used to dispatch first responders to traffic accidents, so it's vital that the time conversion is handled correctly. I'm hoping to find documentation regarding what should be passed to the tz.gettz() function?