[Datetime-SIG] PEP-0500 (Alternative datetime arithmetic) Was: PEP 495 ... is ready ...
Guido van Rossum
guido at python.org
Wed Aug 19 17:55:13 CEST 2015
On Wed, Aug 19, 2015 at 8:38 AM, Carl Meyer <carl at oddbird.net> wrote:
> On 08/19/2015 09:30 AM, Guido van Rossum wrote:
> > Yes, that's the right way to define it (and PEPs should primarily
> > concern themselves with crisp definitions).
> >
> > Isn't it so that you could get timeline arithmetic today by giving each
> > datetime object a different tzinfo object?
>
> Yes. In fact, this is exactly how pytz works around it. With pytz, every
> tzinfo _instance_ is a fixed-offset instance (e.g. there are distinct
> tzinfo instances for EST and EDT). This means if you do arithmetic using
> an EST datetime and an EDT datetime, you'll get (timeline-arithmetic)
> correct results. The downside of this approach (though once you get used
> to it it's at least predictable and explicit) is that if you do
> arithmetic using e.g. an EST datetime and a timedelta, you'll always end
> up with an EST result, even if the result crossed a transition to EDT
> (so it's sort of an "imaginary extension of EST"), and you have to
> remember to use a pytz-specific "normalize()" API, which will adjust the
> datetime by an hour and switch the tzinfo from EST to EDT.
>
That does not sound like what I was proposing (as a hack) -- it simply
exchanges one bug for another.
--
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150819/24a7d5d4/attachment-0001.html>
More information about the Datetime-SIG
mailing list