[Datetime-SIG] A local timezone class

Guido van Rossum guido at python.org
Sat Aug 29 00:53:40 CEST 2015


I've written a simple class that implements a local timezone tzinfo object,
deferring to what the time module exposes about the local zone.

https://gist.github.com/gvanrossum/ef201fe313719305c4c7

There are two variations: one for systems that support tm_gmtoff and
tm_zone, one for systems without those.

Output of the test program:

BetterLocalTimeZone
Fri Aug 28 15:50:22 2015 PDT (-0700)
Wed Feb 24 15:50:22 2016 PST (-0800)

I'm not entirely sure why we didn't add this to the stdlib ages ago. (Maybe
out of a sense of perfectionism, since time.localtime() may be wrong for
dates in the past or future where different DST rules or a different
standard offset apply? But why would we care, if we're fine with the time
module's behavior?)

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150828/a12e3805/attachment.html>


More information about the Datetime-SIG mailing list