How To Get The Local Timezone Given Time And State Info
I am using a combination of Python and Amazon Redshift. I have hits from various users and some data around those hits. This may be visualized in the following format: UTCTime S
Solution 1:
You could approach this problem by using us package. Add it via pip:
$ pip install us
The state lookup method allows matching by FIPS code, abbreviation, and name:
>>>us.states.lookup('24')
<State:Maryland>
>>>us.states.lookup('MD')
<State:Maryland>
>>>us.states.lookup('md')
<State:Maryland>
>>>us.states.lookup('maryland')
<State:Maryland>
as mentioned in us package description, State
object has time_zones
and capital_tz
attributes, which names are self explanitory:
>>> us.states.lookup('MD').capital_tz
'America/New_York'
and
>>> us.states.lookup('MD').time_zones['America/New_York']
Now you can easily translate state abbreviation to full time zone name.
Post a Comment for "How To Get The Local Timezone Given Time And State Info"