[Datetime-SIG] Another round on error-checking

Tim Peters tim.peters at gmail.com
Thu Sep 3 17:05:40 CEST 2015

>> The only "basic arithmetic identities" that are being violated here are
>> the ones that are already violated by aware datetimes.  For example
>> (t1 - u) - (t2 - u) is not equal to t1 - t2
>> if u is a tzinfo=UTC instance and t1 and t2 are two tzinfo=Eastern
>> instances on the different sides of the gap.

> s/gap/fold/

What you said is true either way (fold or gap); the sign of the hour
difference (between the two expressions) just differs.  Although
_sometimes_ the expressions can be equal, if you move t1 and/or t2 far
enough away from the gap/fold to encompass some number of _additional_
gaps/folds, so as to just cancel out overall. As an obvious example,
pick d1 = 2000-01-01 and d2 = 2001-01-01.  They're on different sides
of one gap, but also on different sides of one fold.  Then you get 366
days (2000 is a leap year) via either way of computing the difference.

The conceptual muddying here is that this kind of stuff wasn't
possible before when sticking within a _single_ zone.  We are
introducing oddball cases of timeline arithmetic into what used to be
"surprise-free" classic arithmetic.  I don't like that, but I'm not
scared to death of it either.  Yet ;-)

More information about the Datetime-SIG mailing list