[Datetime-SIG] PEP 495 (Local Time Disambiguation) is ready for pronouncement

Chris Barker chris.barker at noaa.gov
Mon Aug 17 18:44:50 CEST 2015


Great stuff -- thanks for takign the time to write all this up so clearly
-- for what really is a tiny change!

( and very good that that is the only thing this PEP is covering)

My one comment:

It seems that a "missing" time really should be an Error -- like Feb 29th
in a non-leap year.

However, in the PEP:


When a datetime.datetime instance dt represents a missing time, there is no
value s for which:

datetime.fromtimestamp(s) == dt

but we can form two "nice to know" values of s that differ by the size of
the gap in seconds. One is the value of s that would correspond to dt in a
timezone where the UTC offset is always the same as the offset right before
the gap and the other is the similar value but in a timezone the UTC offset
is always the same as the offset right after the gap.

The value returned by dt.timestamp() given a missing dt will be the larger
of the two "nice to know" values if dt.first  == True and the smaller

I _think_ I recall form this discussion that this was done, rather than an
error, because it was decided that such calls should never raise an
exception (also, the replace() functionality makes it all too likely). So
it's probably best to do it in the proposed way, but the PEP should make it
clear that a prime motivation is to avoid Exceptions in such code.


On Sat, Aug 15, 2015 at 5:49 PM, Alexander Belopolsky <
alexander.belopolsky at gmail.com> wrote:

> PEP 495 [1] is a deliberately minimalistic proposal to remove an
> ambiguity in representing some local times as datetime.datetime
> objects.
> The concept has been extensively discussed on python-ideas and this
> mailing list.  I believe a consensus has been reached and it is
> reflected in the PEP.
> PEP 495 does not propose any changes to datetime/timedelta
> arithmetics, but it has been agreed that it is a necessary step for
> implementing the "strict" rules.
> [1]: https://www.python.org/dev/peps/pep-0495
> _______________________________________________
> Datetime-SIG mailing list
> Datetime-SIG at python.org
> https://mail.python.org/mailman/listinfo/datetime-sig
> The PSF Code of Conduct applies to this mailing list:
> https://www.python.org/psf/codeofconduct/


Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150817/757fd578/attachment.html>

More information about the Datetime-SIG mailing list