On 08/18/2015 01:06 PM, Tim Peters wrote: > [Carl Meyer <[email protected]>] >> `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.)
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Datetime-SIG mailing list [email protected] https://mail.python.org/mailman/listinfo/datetime-sig The PSF Code of Conduct applies to this mailing list: https://www.python.org/psf/codeofconduct/
