[Datetime-SIG] Another round on error-checking

Carl Meyer carl at oddbird.net
Thu Sep 3 16:52:06 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.

Yes, you can already get such results, because aware datetimes are
already sometimes aware and sometimes naive depending on context. That's
a problem for learning the API, but it's at least an easily-explained
problem: arithmetic within a timezone is always naive, arithmetic
between timezones is always aware, if you mix the two (as your example
does) you may get surprising results.

I don't see any such easily comprehensible explanation for the new
proposed PEP 495 behavior. It is no longer true that "arithmetic within
a timezone is always naive." Now "arithmetic within a timezone is naive,
unless you happen to have a particular kind of special time in a single
hour once per year, in which case some kinds of arithmetic (dt/dt) are
aware of the DST transition, but other kinds (dt/delta) still ignore
it." Is that roughly what you propose to put in the documentation?

Currently you only get results that violate arithmetic identities if you
mix arithmetic within a timezone and arithmetic between timezones.
Again, a simple rule. Under PEP 495, you can get such results even if
you always stay within a single timezone.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150903/1282153f/attachment-0001.sig>

More information about the Datetime-SIG mailing list