Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #96455

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

Path csiph.com!news.mixmin.net!news.albasani.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <random832@fastmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:: [': 0.03; 'context': 0.05; 'important,': 0.07; 'api': 0.09; 'attribute.': 0.09; 'behave': 0.09; 'preserves': 0.09; 'received:internal': 0.09; 'semantics': 0.09; 'sfxlen:2': 0.10; 'explicitly': 0.15; 'message-id:@webmail.messagingengine.com': 0.16; 'naive': 0.16; 'noon': 0.16; 'offsets': 0.16; 'opposite': 0.16; 'peters': 0.16; 'pressed': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:10.202.2.212': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:messagingengine.com': 0.16; 'utc': 0.16; 'wrote:': 0.16; 'first.': 0.18; 'subject:] ': 0.19; 'posted': 0.21; 'work,': 0.21; 'to:2**1': 0.21; 'not,': 0.22; 'saying': 0.22; '(by': 0.22; 'sep': 0.22; 'subject:skip:i 10': 0.22; 'trying': 0.22; '(or': 0.23; 'replacing': 0.23; 'sat,': 0.23; 'second': 0.24; 'tim': 0.24; 'header:In-Reply-To:1': 0.24; "i've": 0.25; "doesn't": 0.26; 'figure': 0.27; 'question': 0.27; 'transition': 0.27; 'idea': 0.28; 'looks': 0.29; 'arithmetic': 0.29; 'tonight,': 0.29; 'objects': 0.29; "i'm": 0.30; 'to:name :python-list': 0.30; 'supposed': 0.31; 'another': 0.32; 'maybe': 0.33; 'third': 0.33; 'similar': 0.33; 'correctly': 0.34; 'could': 0.35; 'replaced': 0.35; 'something': 0.35; 'asking': 0.35; 'according': 0.36; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'alone': 0.36; 'subject:" ': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'received:10': 0.37; '12,': 0.37; 'thought': 0.37; 'list.': 0.37; 'seem': 0.37; 'doing': 0.38; 'received:66': 0.38; 'button': 0.38; 'wrong': 0.38; 'end': 0.39; 'why': 0.39; "didn't": 0.39; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'still': 0.40; 'from:no real name:2**0': 0.60; 'skip:u 10': 0.61; 'header:Message-Id:1': 0.61; 'side': 0.62; 'real': 0.62; 'leaving': 0.63; 'different': 0.63; 'hours': 0.65; 'today': 0.65; 'subject:there': 0.66; 'results': 0.66; 'day': 0.67; 'reply': 0.68; 'as:': 0.79; 'faithfully': 0.84; 'function)': 0.84; 'lands': 0.84; 'subject:any': 0.84; 'tomorrow,': 0.84; 'back"': 0.91; 'subject:Are': 0.95
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=EA2AeSXRH4m8aHludqUmP0lK4/Q=; b=cHe5JY S2PK5NmKDqzd3OcfxmPODhwNAFOWYfscqsg1yrD6dYzZC2QUqTG/jEoxGtXrCXlQ 9rtd0J4cTCdR9CTEp8zhFy/QLBokvq4+JPKGRCtFCWosBLnnmfkMtEXpPbI1Hc54 OaOMT6TneJIwyKxCo+DrcKYrHtiUFUyyXluGw=
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=EA2AeSXRH4m8aHl udqUmP0lK4/Q=; b=Ji7o43IzcL93peufyl/iergk3ddJxb3hugdsQspLXQNJvqo 9JCZW9iE6BsbS5tnJm/xgFbiEtvr4g+n5rMipWMjgwxxHauN5/1/HVpjLvpPQRyO GBUwghE0ka/NloWRWEW1oSvxTQoJD77mofmu4NrCBQ/GBhJnvha8ao0oyXEc=
X-Sasl-Enc e4a9eIJ65Tt6fNAQl9ulFb88MEweHVAPJ7qwbUysx7yI 1442085362
From random832@fastmail.com
To "Python-List" <python-list@python.org>, "datetime-sig" <datetime-sig@python.org>
MIME-Version 1.0
Content-Transfer-Encoding 7bit
Content-Type text/plain
X-Mailer MessagingEngine.com Webmail Interface - ajax-c76b43ce
Subject Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?
Date Sat, 12 Sep 2015 15:16:02 -0400
In-Reply-To <CAExdVNm0rrxhbSONfQdor7e=9t+6Tg3hh6eFq-h0NnfdpteVYg@mail.gmail.com>
References <m2h9mzqyy7.fsf@fastmail.com> <CAExdVNm0rrxhbSONfQdor7e=9t+6Tg3hh6eFq-h0NnfdpteVYg@mail.gmail.com>
X-Mailman-Approved-At Sat, 12 Sep 2015 22:03:18 +0200
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.446.1442088200.8327.python-list@python.org> (permalink)
Lines 43
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1442088200 news.xs4all.nl 23725 [2001:888:2000:d::a6]:36564
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:96455

Show key headers only | View raw


Oops, pressed the wrong reply button and it didn't include the datetime
list.

On Sat, Sep 12, 2015, at 14:53, Tim Peters wrote:
> > I was trying to find out how arithmetic on aware datetimes is
> > "supposed to" work, and tested with pytz. When I posted asking why
> > it behaves this way I was told that pytz doesn't behave correctly
> > according to the way the API was designed.
>
> You were told (by me) that its implementation of tzinfos was not the
> _intended_ way.  Which is another way of saying it was an
> unanticipated way.  "Correctly" is a whole different kind of judgment.
> pytz users who faithfully follow the docs seem happy with it.

My context is that I am working on an idea to include utc offsets in
datetime objects (or on a similar object in a new module), as an
alternative to something like a "fold" attribute. and since "classic
arithmetic" is apparently so important, I'm trying to figure out how
"classic arithmetic" _is actually supposed to work_ when adding a
timedelta to a time lands it on the opposite side of a transition (or in
the middle of a "spring forward" gap).

If there is a "fall back" transition tonight, then adding a day to a
time of 12 noon today could end up as:

12 noon tomorrow, offset still DST.
12 noon tomorrow, offset in standard time, 25 hours from now in real
time.
11 AM tomorrow, offset in standard time, 24 hours from now in real time

Which one of these is "classic arithmetic"? Pytz (if you don't
explicitly call a "normalize" function) results in something that looks
like the first. In one of the models I've thought of, you can get the
second by replacing the tzinfo again, or the third by doing astimezone,
but the first preserves "exactly 24 hours in the future" in both the UTC
moment and the naive interpretation by leaving the offset alone even if
it is an "unnatural" offset.

The second one above is what you get when you call normalize.

My question was whether there are any real implementations that work the
intended way. If there are not, maybe the intended semantics should go
by the wayside and be replaced by what pytz does.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo? random832@fastmail.com - 2015-09-12 15:16 -0400

csiph-web