[Chicago] Working with timezones

Chris Sinchok chris at sinchok.com
Fri Nov 18 16:47:47 EST 2016


You maybe try something like this:

>>> zone = pytz.timezone('America/Chicago')
>>> [tzname for tzname in pytz.all_timezones if
pytz.timezone(tzname)._utcoffset == zone._utcoffset]
['America/Chicago', 'US/Central']

- Chris

On Fri, Nov 18, 2016 at 3:30 PM, Chris Foresman <foresmac at gmail.com> wrote:

> Yeah, it’s a little more processing intensive  than I would like, but
> it’ll do. Thanks!
>
>
> Chris Foresman
> foresmac at gmail.com
>
>
>
>
> > On Nov 18, 2016, at 3:07 PM, Jordan Bettis <jordanb at hafd.org> wrote:
> >
> > You shouldn't have to build your own database, and that would be a
> > herculean task in any case. The Olsen database what everyone already
> > uses (including pytz).
> >
> > This SO question seems to be close to what you want. There are several
> > answers but they all revolve around iterating the Olsen database, mainly
> > through pytz, which does expose it in python:
> >
> > http://stackoverflow.com/questions/7669938/get-the-
> olson-tz-name-for-the-local-timezone
> >
> > On 11/18/2016 02:33 PM, Chris Foresman wrote:
> >> Ugh, dealing with time/timezones is the worst, AMIRITE? Here’s what I
> need to do:
> >>
> >> Calculate an offset from UTC, and use the offset to get a list of
> corresponding timezone names, i.e., I’ve detmerined that I need all the
> timezones associated with offset -06:00; which includes “America/Chicago”,
> “CT”, etc. I looked at pytz, but it looks like it only goes the other
> direction, i.e. pytz.timezone(‘America/Chicago’) will give me a tzinfo
> instance with UTC offset -06:00.
> >>
> >> Outside of building my own reverse database, does anyone have ideas how
> to make this work?
> >>
> >>
> >> Thanks,
> >> Chris Foresman
> >> foresmac at gmail.com
> >>
> >>
> >>
> >>
> >> _______________________________________________
> >> Chicago mailing list
> >> Chicago at python.org
> >> https://mail.python.org/mailman/listinfo/chicago
> >>
> >
> > _______________________________________________
> > Chicago mailing list
> > Chicago at python.org
> > https://mail.python.org/mailman/listinfo/chicago
>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> https://mail.python.org/mailman/listinfo/chicago
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20161118/48dc8039/attachment.html>


More information about the Chicago mailing list