[Datetime-SIG] Conversion vs arithmetic (was Re: Is EDT a timezone? Was: PEP-0500)
carl at oddbird.net
Tue Aug 25 01:55:23 CEST 2015
On 08/24/2015 05:23 PM, Alexander Belopolsky wrote:
> On Mon, Aug 24, 2015 at 7:01 PM, Carl Meyer <carl at oddbird.net
> <mailto:carl at oddbird.net>> wrote:
> On 08/24/2015 03:58 PM, ISAAC J SCHWABACHER wrote:
> > [ijs]
> >>> I see how PEP 495 makes it possible to convert datetimes correctly
> >>> in all cases,
> > [Tim Peters]
> >> Whew! You may well be only the second person to grasp this - thanks :-)
> > Wait... was this ever in contention?
> I don't think so. I'm not sure what Tim is referring to here; I haven't
> seen any messages in this thread that indicated a lack of understanding
> on this point.
> I cannot speak for Tim, but here is an exercise you can try to check
> your grasp of PEP 495: given PEP-compliant utcoffset() and dst() methods
> for the current rules in the US/Eastern timezone, write a PEP-compliant
> fromutc(). You can start from the current datetime.py implementation. 
> : https://hg.python.org/cpython/file/v3.5.0rc1/Lib/datetime.py#l957
Looks fun; I'll give it a try later tonight.
But you're changing the subject. That exercise requires far more
detailed knowledge of the tzinfo APIs than is required to understand
that a single added disambiguating bit is enough to handle timezone
conversions, even in the presence of (two-layered) folds and gaps.
I haven't seen anyone object to PEP 495 on the grounds that it doesn't
provide enough information to handle timezone conversions (well, except
in the as-yet-hypothetical case of a three-layered fold, which could be
handled by your latest proposal to make `ltdf` an integer rather than a
boolean). I've seen a lot of discussion of the name of the flag, and a
couple people express a desire to have a simpler built-in spelling of
"raise an exception on invalid/ambiguous time" than "convert twice with
two different flag values and compare the results".
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 819 bytes
Desc: OpenPGP digital signature
More information about the Datetime-SIG