[Datetime-SIG] PEP 495 (Local Time Disambiguation) is ready for pronouncement

Carl Meyer carl at oddbird.net
Tue Aug 18 21:24:53 CEST 2015


On 08/18/2015 01:06 PM, Tim Peters wrote:
> [Carl Meyer <carl at oddbird.net>]
>> `t.replace(later=True) - t.replace(later=False) < 0` certainly seems
>> wrong, but why would it be implemented that way?
> 
> So that from the two values alone it's possible to distinguish among
> the 3 possibilities:  the time is ambiguous, the time is invalid (in a
> gap), or the time is ordinary - corresponding to which of  ">", "<",
> or "=="  obtains.
> 
> I'd probably be happier requiring, e.g., a new `classify()` tzinfo
> method to give a direct answer, but that would be a new burden.
> Tricking other methods into giving another way to distinguish is at
> worst defensible.

Yes, I see. In that case I think `later` and `first` are both poor
choices for the name of the flag. A comprehensible name that sometimes
means the opposite of its plain English meaning is arguably worse than
an incomprehensible name :-)

I too wish the PEP offered a nicer way to detect ambiguous or missing
times than "guess in both directions and see how they differ" -- but I'm
not familiar enough with the core datetime timezone APIs to propose what
that should be. (I'm afraid that I've been unrecoverably corrupted by
too many years of using pytz's API, which requires that you never touch
any of the built-in timezone API.)

Carl

(Btw, Tim, sorry I never replied to your gracious response to my "essay"
[rant] about timeline arithmetic a couple weeks ago; I was traveling and
didn't find the time. Your response was interesting, and on target
primarily in demonstrating how relative "correct" is. Personally I
couldn't care less about leap seconds, and my careless misuse of the
term "astronomical time" reflected how little I know or care about them,
not my interest in them. I still think that ideally the default behavior
of datetime arithmetic with tz-aware datetimes should be timeline
arithmetic, and naive datetimes should be used when "classic" arithmetic
is desired -- but obviously that fails backward-compatibility.)

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


More information about the Datetime-SIG mailing list