[Python-Dev] TZ-aware local time
R. David Murray
rdmurray at bitdance.com
Wed Jun 6 04:05:38 CEST 2012
On Tue, 05 Jun 2012 18:31:20 -0700, Glyph <glyph at twistedmatrix.com> wrote:
>
> Le Jun 5, 2012 à 6:16 PM, Nick Coghlan a écrit :
>
> > Personally, I'd like to see the datetime module make an explicit
> > assumption that "all naive datetime objects are considered to be UTC",
> > with the interactions between naive and aware objects updated
> > accordingly
>
> I would absolutely love it if this were true. In fact, I would go a step further and say that the whole concept of a "naive" datetime is simply a bug. We don't have a "naive" unicode, for example, where it's text in some encoding but you decline to decide which one when you decode it, leaving that to the caller.
>
> When we addresed this problem for ourselves at Divmod some time ago, naive=UTC is exactly what we did:
>
> <http://bazaar.launchpad.net/~divmod-dev/divmod.org/trunk/files/head:/Epsilon/epsilon/extime.py>
Note that (after several conversations with Alexander, and based on the
analogous decision in the email RFCs), the email package makes the same
call. A naive datetime is treated as a UTC time with no information
about what timezone it originated from (coded as -0000 per RFC 5322),
while an aware datetime will generate an accurate offset (+0000 for
"really UTC", and as appropriate for others).
So in some sense I've already nudged the stdlib in this
direction...unless I get overruled now that I've pointed it out :)
--David
More information about the Python-Dev
mailing list