On Wed, Sep 9, 2015 at 12:10 PM, Tim Peters <[email protected]> wrote: > [Alex] >>> Definitions: An aware datetime value t is called "regular" if t.utcoffset() >>> does not depend on the value of the fold attribute. > > [Chris Angelico] >> One point to clarify here. Is the definition of "regular" based on the >> timezone alone (that is to say, a UTC datetime is regular, and an >> Australia/Brisbane datetime is regular, but anything in a region with >> DST is always special), or are "special" datetimes only those in the >> fold period? > > It applies to "an aware datetime value t". That's clear already ;-) > Everything about `t` matters. In plain English `t` is "regular" if > and only if `t` is in neither a fold nor a gap. So, e.g., all `t` in > UTC are regular. In most zones with a notion of DST, there are > exactly 2 wall-clock hours per year that are not regular (in the gap > at the start of DST, and in the fold at DST end).
Okay, that's what I thought it meant. And it's easy enough to see if two datetimes differ only in fold. The problem I was seeing was a difficulty in recognizing whether a single datetime is special or not, which is answered here: On Wed, Sep 9, 2015 at 12:02 PM, Alexander Belopolsky <[email protected]> wrote: > If you want to know whether t is regular you have to compare t.utcoffset() > and t.replace(fold=1-t.fold).utcoffset(). If they are the same, t is > regular. If not - t is special. Thanks Alex! (I can imagine pushing this to the timezone object as a primitive, which will allow it to be optimized down to "t is regular" for timezones that are always regular, but that's an optimization only.) ChrisA _______________________________________________ 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/
