|| ||Guido van Rossum <guido-AT-python.org> |
|| ||Glyph <glyph-AT-twistedmatrix.com> |
|| ||Re: TZ-aware local time |
|| ||Tue, 5 Jun 2012 20:14:45 -0700|
|| ||Nick Coghlan <ncoghlan-AT-gmail.com>, python-dev-AT-python.org|
|| ||Article, Thread
On Tue, Jun 5, 2012 at 6:31 PM, Glyph <email@example.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
> 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:
You can try to enforce this, but users will ignore it, and happily
represent local time as UTC. I've seen people do this with POSIX
timestamps too -- use the UTC conversions between timestamps and time
tuples, and yet use time tuples to represent local time (the
timestamps are stored because integers are easier to store). And yes
they get in horrible trouble around DST and they don't understand why.
But they still do it.
I think it's better to give users the rope they want than to try and
prevent them from hanging themselves, since otherwise they'll just use
the power cords as ropes and electrocute themselves.
--Guido van Rossum (python.org/~guido)
to post comments)