[Datetime-SIG] PEP 495: What's left to resolve
tim.peters at gmail.com
Wed Sep 9 05:10:56 CEST 2015
>> 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.
> (I can imagine pushing this to the timezone object as a primitive,
Hey, I'm listed as a PEP co-author, and even I can't get Alex to budge
on adding my utterly sensible new ".classify()" tzinfo method ;-)
Instead zone-wrapping tzinfo authors will likely write one anyway for
their internal use, but not expose it (e.g., a tzinfo's .fromutc()
needs to compute "is this in a fold? if so, earlier or later time?:"
each time it's called - and .utcoffset() needs to worry about both
folds and gaps on each call).
> which will allow it to be optimized down to "t is regular" for
> timezones that are always regular, but that's an optimization only.)
Any sensible wrapping of a fixed-offset ("always regular") zone will
have a 1-line .utcoffset() implementation, simply returning that
zone's constant offset. It will be cheap enough.
More information about the Datetime-SIG