[Datetime-SIG] PEP 495 and the hardest problem in computer science

Alexander Belopolsky alexander.belopolsky at gmail.com
Wed Jun 29 14:56:25 EDT 2016


On Wed, Jun 29, 2016 at 2:35 PM, Random832 <random832 at fastmail.com> wrote:

> Er, I was talking about using it as a naive time using the london
> timezone.
>

Well, "a naive time using a timezone" is a misnomer.


> Basically, the opposite of what you did: converting that naive
> time _from_ London time (you should be able to convert it from any
> timezone, after all, since it's naive) _to_ some other timezone.
>

And you can:

>>> New_York = ZoneInfo.fromname('America/New_York')
>>> print(t0.replace(tzinfo=New_York).astimezone(timezone.utc))
2016-11-06 05:30:00+00:00
>>> print(t1.replace(tzinfo=New_York).astimezone(timezone.utc))
2016-11-06 06:30:00+00:00
>>> print(t0.replace(tzinfo=London).astimezone(timezone.utc))
2016-11-06 01:30:00+00:00
>>> print(t1.replace(tzinfo=London).astimezone(timezone.utc))
2016-11-06 01:30:00+00:00

Note that the result of conversion to UTC is different for t0 and t1 when
they are interpreted as NY times, but the same when they are interpreted as
London time.

I think this all has been explained in the PEP, but discussions like this
may be helpful for writing the documentation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20160629/d7b19f78/attachment.html>


More information about the Datetime-SIG mailing list