[Datetime-SIG] Adding PEP 495 support to dateutil
alexander.belopolsky at gmail.com
Fri Sep 18 21:01:16 CEST 2015
On Fri, Sep 18, 2015 at 2:42 PM, Tim Peters <tim.peters at gmail.com> wrote:
> When converting from UTC to a local ambiguous time, you obviously know
> which UTC time you started with. The problem is that it's impossible
> to _record_ which UTC time you started with. The date and time
> attributes of the local datetimes are (must be) identical, so the only
> way you _could_ record it is by overriding .fromutc() to attach a
> different tzinfo object (the only bits of a datetime object that could
> possibly differ between the earlier and later of an ambiguous local
> Which is what pytz does.
The pytz hack is in violation of the strict reading of the reference manual
 which says "The purpose of fromutc() is to adjust the date and time
data ...". I think it is in the spirit if not in the letter of datetime
module design that fromutc(dt) should not change dt.tzinfo.
In any case, I think we have concluded on this list that pytz approach is
not an example to be followed. I just wanted to mention for Paul's benefit
that it is not just the arithmetic that is affected by the pytz hack. The
changes in arithmetic are themselves consequences of the violation of the
"fromutc(dt).tzinfo is dt.tzinfo" invariant.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Datetime-SIG