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


Groups > comp.lang.python > #96456

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

Path csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!usenetcore.com!newsfeed.xs4all.nl!newsfeed7.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; '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; '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; '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; '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; 'seem': 0.37; 'doing': 0.38; 'received:66': 0.38; 'end': 0.39; 'why': 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; '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=vm6qsjuS82xLsK3DXSmFyf1+GyE=; b=z2MTcq iYoPtWN2aGfSRs8Ai2m94620rPONIgbxwKlR6A5bI6QZmXhoASV/4kqYt03DOGLx QQPY3KgGzKcng/DgwkyT2Pd4NVG9wup7mTs2WPsQpdFYRUeCccb1LLMa3C1K44A0 hAVasRAG8mmiNyQKqP0sM/O+mrpheUBNrTsHw=
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=vm6qsjuS82xLsK3 DXSmFyf1+GyE=; b=oKvc05/FEgIXuL4Fg0mZ1eSuptU+p+58wGcUEcQ52NrgcW5 Y6Iizftsl9KJfPReKwj1fMxp5Zc9XoPtrgpTp0z7l1KkFfQFVK5N89h08PbPHwvY ZyrArn4djXlNTt+lvGwNgjU8dEBj0GjKVzHPDBBXf38xxPPfiiUfioQWLJN8=
X-Sasl-Enc w39pLlGItr7bwmLq6GJ6hgYSixfOMesezdHzDoS5BWUr 1442085270
From random832@fastmail.com
To python-list@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:14:30 -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.445.1442088200.8327.python-list@python.org> (permalink)
Lines 40
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1442088200 news.xs4all.nl 23867 [2001:888:2000:d::a6]:36562
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:96456

Show key headers only | View raw


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:14 -0400

csiph-web