More than a few, state is really the wrong resolution here, US timezones follow counties and native reservations borders.
ZIP codes should probably be good enough but I'd be careful too. If your volume of addresses isn't too crazy, the robust way is to reverse geocode them and use a library that gets you the IANA identifier from timezone shapes.
https://github.com/RomanIakovlev/timeshape is maintained by a former coworker who could open source some of the work we did internally.
Can't remember the code for it now, had a lot of interesting timezone issues in a previous job.
Also IIRC (cum grano salis) the federal buildings in the Hopi reservation do observe DST and the state buildings in the Navajo reservation don't. But don't quote me on any of those actually existing.
A fun fact circa 2012 was I was writing a PHP server that needed to talk to a Windows server to schedule things. Windows server used Microsoft's own timezone system, not IANA or anything like that. I went looking for an implementation of IANA <-> MS conversion. I ended up finding all these forum posts by Windows Phone (RIP) users in Arizona who had the wrong time on their phones. So it was nice to know that 1) there was no fixing it and 2) they eat their own dogfood.
County is the smallest resolution one can reasonably use, but in terms of what timezones themselves follow, that would be metro areas. I.E. the Chicago metro area has its timezone and cities (or counties, if you will) that are part of that metro region, even when belonging to other states that largely follow a different time zone, follow the metropolis’ tz instead.
(Not arguing with you but clarifying the meaning of “follow” here.)
It's worse than that; Malheur County on the eastern border of Oregon is split between Pacific and Mountain time based on whether cities are more economically connected to Idaho or Nevada: https://en.wikipedia.org/wiki/Malheur_County,_Oregon#Time_zo...
The almanac gave nominal rules for the transitions. But there was a footnote explaining that these transitions had and will continue to be adjusted year to year due to Congressional intervention. I showed this to my boss and said, "If I could write an algorithm that predicted future votes of Congress, I would be a billionaire and could quit this engineering job."
I think in the end I coded the algorithm with the recent known transitions, and the nominal rules for future ones. What else could you do (this was before everyone was networked, and the code ran on standalone computers like a VAX).
I also learned that task of merging three sources of tracking data, each with its own validity and measurement degradation status, was an absolute nightmare. But still easier than predicting future actions of Congress.
The named timezone is special as it is constant. The UTC offset timezone (e.g. "-05:00") and the shorthand name (e.g. "EST") is NOT constant over time for a given location, because of daylight savings time. "US/Eastern" flips between "-05:00" and "-05:00", as well as between "EDT" and "EST".
If you ask someone what their timezone is and offer them offsets or the short names, it causes confusion for everyone.
I also did something similar earlier this year, though I used a geolocation service to translate address to lat/long coords, and then used lat/long to translate to timezone. (With shortcuts single-timezone states)
I ended up using this python library for lat/long -> timezone converstion:
https://github.com/jannikmi/timezonefinder
Which sources its data from here, which seems like a pretty high quality source:
https://github.com/evansiroky/timezone-boundary-builder/rele...
> POSIX has positive signs west of Greenwich, but many people expect positive signs east of Greenwich. For example, TZ='Etc/GMT+4' uses the abbreviation "-04" and corresponds to 4 hours behind UT (i.e. west of Greenwich) even though many people would expect it to mean 4 hours ahead of UT (i.e. east of Greenwich).