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

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


On Wed, Jun 29, 2016 at 1:21 PM, Random832 <random832 at fastmail.com> wrote:
>
> Of course, naive times that care about the 'fold' are only portable to
> other timezones that have a fold at the same local time - e.g. among US
> timezones (which all have a fold from 2AM to 1AM local) but not EU
> timezones (which all transition at the same UTC time and therefore
> different local times).


I don't think you are correct.  With the current Github implementation [1]
of the PEP, I can do the following:

>>> from datetime import *
>>> from test.datetimetester import ZoneInfo
>>> London = ZoneInfo.fromname('Europe/London')
>>> t0 = datetime(2016, 11, 6, 1, 30, fold=0)
>>> t1 = datetime(2016, 11, 6, 1, 30, fold=1)
>>> print(t0.astimezone(London))
2016-11-06 05:30:00+00:00
>>> print(t1.astimezone(London))
2016-11-06 06:30:00+00:00

In the snippet above, t0 and t1 are "naive times that care about the
'fold'."  (My system TZ is US/Eastern.)  I am not sure what you mean by
being portable, but I can convert either of those times to London Time
using .astimezone() which assumes local timezone for naive instances.

I am afraid Dan was right when he wrote: "And yet, it will still be
confusing, because of how complicated time is in general, and of how humans
interpret words." [2]  I can only hope that once PEP is implemented, most
of the confusion can be resolved by experimentation.

[1]: https://github.com/python/cpython/pull/20
[2]:
http://blog.danwin.com/pep-495-and-the-hardest-problem-in-computer-science/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20160629/aa378c87/attachment.html>


More information about the Datetime-SIG mailing list