[Datetime-SIG] Another round on error-checking

Alexander Belopolsky alexander.belopolsky at gmail.com
Wed Sep 2 19:40:15 CEST 2015


On Wed, Sep 2, 2015 at 1:20 PM, Tim Peters <tim.peters at gmail.com> wrote:

> [Alex]
> > There are two more cases:
> >
> > (1) datetime.now() will return fold=1 instances during one hour each
> year;
> > (2) datetime.fromtimestamp(s) will return fold=1 instances for some
> values
> > of s.
>
> Sure - but anything reflecting how a local clock actually behaves is
> outside of "naive time".  Clocks in naive time never jump forward or
> backward.  Specifically, .now() and .fromtimestamp() are also
> operations outside of naive time.
>

I agree, but the worst thing we can do to our users is to plant a time bomb
that will go off once a year.  Suppose someone has a program that uses
naive local times and relies on t < prev_t test to detect the fall-back
fold and do something about it.  If we don't ignore fold in naive datetime
comparisons - this program will start producing incorrect results.

Fortunately, we don't need to do anything about naive times.  The hash
invariant is only violated by aware instances.

I think what you are really fighting against is the notion that for regular
times, fold=1 is just an alternative spelling for fold=0 times.  It looks
like you would rather see fold=1 as some different (and invalid) time.

Think of the German A and B hours: are regular hours A or B?  The German
standard say that they are neither, but PEP 495 say that they are both: 2A
is the same as 2B  unless "2" in the fold and that allows you not to
display A/B in those cases.

Folds do not exist in naive time, so all times are regular and therefore
time(h, m, s, us,  fold=0) == time(h, m, s, us,  fold=1) always.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150902/7d2a540f/attachment.html>


More information about the Datetime-SIG mailing list