[Datetime-SIG] Another round on error-checking

Alexander Belopolsky alexander.belopolsky at gmail.com
Thu Sep 3 01:05:04 CEST 2015


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

> There are still questions, like, e.g., what
>
>     fold_aware_datetime + timedelta
>
> should do when fold=1, but only in my variation of what you proposed.
> You proposed mixing "pay attention to fold" with "timeline
> arithmetic", which leaves no choice.  Alex and I seem to disagree
> about what to do when "only pay attention to fold" is meant instead.
>

This is one of those cases where I don't have a strong opinion.  Unlike the
datetime - datetime case where we have a strong argument to do timeline
arithmetic in the presence of fold=1 (namely to preserve the hash
invariant),
any choice here will lead to surprises.

What should [01:30/fold=1] - (1 hour) yield?  Given that [01:30/fold=0] +
(1 hour) = [02:30/fold=0] and  [00:30/fold=0] + (1 hour) = [01:30/fold=0],
both answers [01:30/fold=0] and [00:30/fold=0] are equally wrong.  The
third possibility,  [00:30/fold=1] is probably more wrong than the first
two.

Whatever logic we will end up implementing will likely need to be modified
by the applications to fit their needs.  In this case, I think we need to
provide the faster to compute option so that applications don't end up
undoing some expensive operations.

As Guido said, arithmetic is a way to move the hands of the clock.  It does
not need to be a way to mess with the fold attribute.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150902/72fcf656/attachment.html>


More information about the Datetime-SIG mailing list