[Datetime-SIG] Another round on error-checking
carl at oddbird.net
Thu Sep 3 05:36:21 CEST 2015
>>> 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.
> I do: it should ignore fold=1. Precisely the opposite of what you
> _thought_ I've been saying ;-)
>> 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),
> And total ordering, and equivalence between comparison outcomes and
> subtraction results. There are any number of "common sense"
> invariants that rely on this.
IIUC, choosing this combination of behavior means that it is possible to
have a datetime `dt1` (with fold=1) such that:
dt1 - dt2 => delta
where `fold` is respected in this case, but
dt2 + delta != dt1
because fold is ignored for timedelta arithmetic (but is respected for
equality-checking, because that's necessary to maintain the hashing
Are we really so wedded to maintaining an unpredictable hybrid
naive/aware model for timezone-annotated datetimes that we're willing to
break basic invariants of arithmetic and equality to preserve it?
>> any choice here will lead to surprises.
> Indeed so. So screw it ;-)
An alternative to "so screw it" in the face of this puzzle would be to
choose the option that preserves all the invariants and behaves
predictably in all cases. But I suppose that would make things too easy...
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 836 bytes
Desc: OpenPGP digital signature
More information about the Datetime-SIG