[Python-ideas] Please reconsider the Boolean evaluation of midnight

Andrew Barnert abarnert at yahoo.com
Fri Mar 7 03:09:23 CET 2014


From: Tim Peters <tim.peters at gmail.com>

Sent: Thursday, March 6, 2014 5:19 PM


> No, it's bizarre to attach a timezone to a time object because most
> tzinfo subclasses don't - and can't - know what to return for the UTC
> offset in the absence of - at least - month and day info too.  Hour,
> minute, second and microsecond aren't usually enough to determine
> whether "daylight time" is in effect, and most tzinfo subclasses do
> attempt to model daylight time.  And because daylight time is a
> political conceit, most tzinfo subclasses also need year info.  That
> has nothing to do with whether times are viewed abstractly,
> concretely, etc - it has to do with that time zones generally aren't
> _defined_ in terms of isolated time-of-day info.  It's 7:13 PM in US
> Central.  Is that daylight (CDT) or standard (CST) time?  It's
> impossible to answer.  What's the corresponding UTC time?  Ditto.


Well, a time in Central is useless, but a time in CDT or CST is not, and you can design a library that's smart enough to give you a CDT or CST (as appropriate) time from a Central datetime.

However, I built something like that in a C++ datetime library, and we never found a use for it anywhere. Instead, we just carried the full datetime or recurring-datetime object around as late as possible, and rendered to naive times for display.


More information about the Python-ideas mailing list