Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

I am not now, nor have I ever been, a member of the demigodic party. -- Dennis Ritchie


devel / comp.lang.python / Re: Pre-Pre-PEP: The datetime.timedeltacal class

SubjectAuthor
o Re: Pre-Pre-PEP: The datetime.timedeltacal classChris Angelico

1
Re: Pre-Pre-PEP: The datetime.timedeltacal class

<mailman.149.1650190407.20749.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17904&group=comp.lang.python#17904

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: Pre-Pre-PEP: The datetime.timedeltacal class
Date: Sun, 17 Apr 2022 20:13:13 +1000
Lines: 62
Message-ID: <mailman.149.1650190407.20749.python-list@python.org>
References: <20220416173551.fk6voaa3o25iuewm@hjp.at>
<CAPTjJmqdd4Qwrr72h4Y28dhZ_JXa9VSJFWmHXt4KfD-eNMwOTA@mail.gmail.com>
<20220417081554.wewkrvvl2xmiygsm@hjp.at>
<CAPTjJmoqpOWWrHt7k-vA1Gr9WuoTp6DfDkOp863=g0sY_=VAAQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de NzzU1jTUKMsV40ncV24q6wIOxHh7Sl2JNk1ooBg+6JYA==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=Es2q1TY+;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '2022': 0.05; "python's":
0.05; 'explanation': 0.07; 'happened': 0.07; 'sun,': 0.07; 'utc':
0.07; 'angelico': 0.09; 'cases.': 0.09; 'datetime': 0.09;
"hasn't": 0.09; 'subject:class': 0.09; 'then.': 0.09; 'typically':
0.09; 'yes.': 0.09; '"in': 0.16; '"there': 0.16; '(unless': 0.16;
'arithmetic': 0.16; 'chrisa': 0.16; 'found.': 0.16;
'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16;
'holzer': 0.16; 'hours,': 0.16; 'odd': 0.16; 'okay,': 0.16;
'received:209.85.221.47': 0.16; 'received:mail-
wr1-f47.google.com': 0.16; 'semantics': 0.16; 'subject:Pre': 0.16;
'subject:skip:d 20': 0.16; 'third-party': 0.16; 'timezone': 0.16;
'troll': 0.16; 'useful.': 0.16; 'wikipedia': 0.16; 'wrote:': 0.16;
'problem': 0.16; 'to:addr:python-list': 0.20; "i've": 0.22;
'saying': 0.25; 'seems': 0.26; 'months,': 0.26; 'object': 0.26;
"isn't": 0.27; 'done': 0.28; 'chris': 0.28; 'think': 0.32;
'question': 0.32; '"this': 0.32; 'same,': 0.32; 'weeks,': 0.32;
'message-id:@mail.gmail.com': 0.32; 'but': 0.32; "i'll": 0.33;
'there': 0.33; 'same': 0.34; 'mean': 0.34; 'header:In-Reply-To:1':
0.34; 'received:google.com': 0.34; 'handling': 0.35; 'track':
0.35; 'understood': 0.35; 'from:addr:gmail.com': 0.35; 'those':
0.36; "it's": 0.37; 'received:209.85': 0.37; 'way': 0.38; 'could':
0.38; 'received:209': 0.39; 'two': 0.39; 'added': 0.39; 'adding':
0.39; 'subject:PEP': 0.39; 'still': 0.40; 'exact': 0.40;
'seconds': 0.40; 'forward': 0.62; 'migration': 0.62; 'days': 0.62;
'hours': 0.63; 'between': 0.63; 'day': 0.66; 'that,': 0.67;
'days,': 0.69; 'natural': 0.69; 'varying': 0.69; 'subject:The':
0.70; 'perfect': 0.82; 'direction.': 0.84; 'do).': 0.84;
'exceptions': 0.84; 'oslo': 0.84; 'postgresql': 0.84; 'shortage':
0.84; 'summer,': 0.84; 'utc+2': 0.84; 'weird': 0.84; 'opposite':
0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=8H2SVsj6fzw+D1cHxYjgtJxVhLuxC72pi8qif0J4pdQ=;
b=Es2q1TY+hsUKMU1FUPukp/FPKria6Fb+NgPy3HHpoM+8q3mbacXWOA8lI00SFS8QN9
g8033GY3IAHlRwYv1jq/W84kqtzjOD3eWxy0alo8usq5uW+OPy08129T8tzQLqxi97AL
UBd+nkU2wAvAiUdPLLa6eA2GsmPVQIpbaaLjL+V11H6l1/mJx60fB/Bjn43DOGWwXw0H
r7hCArry8CaQE5Rsb0H+Lp3nkzcljjAzrUYihJgVPjIk0bK7rZ6RTNz4RWxC3A8p1pBK
zAFLNSe+vItzxPPaoVXNMTTWWiMDUvnBl3ZlxfyNHg5xOyiTDJdbX65tP9Xuq+MtUBk9
8MCA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=8H2SVsj6fzw+D1cHxYjgtJxVhLuxC72pi8qif0J4pdQ=;
b=xeMBrQuOnBxAEKdza06KayJBUT5ye4hbjfIjl0Laa37ZmJb8qR+Tzi4huQhsG2Fh83
N2IPjEA4twpkFbLttIkQL7rkCQFPf1cb5FDan6he/7NgXzTeWZtyzbHHYAW2kv1AhfaN
ghX2UtmPSKAt04DOCWqV6vwIfxCiivpGE9WKoizFMTg200Rla6Uou2MoP+W60uLX018z
TkKUO2G2UFmIan08f3SXkoW4xGSVbPNqh7W9URrV4SdeGH6udUmgNMYzsqCW1n/dAmEd
DygzLqKcEPjHzv9frE0yidmNzDgaO598AkR0VaWrhUS7OpraugSUy3im7M3rir51iYNS
lhVw==
X-Gm-Message-State: AOAM533Vd1+H2a4QFflY9mrUabJtjgeWFJegah/nFVmTRgqxP7nuitMO
MKYMd9xJGRwf2ojlRSCcOA66q/suxLcxbZC+kPKGClxc
X-Google-Smtp-Source: ABdhPJzRKEjsbYiFPphT8M/R/6F49Of0GbOXaYchvKx6WBmxHg7vZIgXqJBqGcRTEyEhn8G2wVAXiLN+f5tWae8QGUs=
X-Received: by 2002:a5d:64eb:0:b0:20a:8d83:7d31 with SMTP id
g11-20020a5d64eb000000b0020a8d837d31mr2909731wri.160.1650190405047; Sun, 17
Apr 2022 03:13:25 -0700 (PDT)
In-Reply-To: <20220417081554.wewkrvvl2xmiygsm@hjp.at>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
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: <https://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>
X-Mailman-Original-Message-ID: <CAPTjJmoqpOWWrHt7k-vA1Gr9WuoTp6DfDkOp863=g0sY_=VAAQ@mail.gmail.com>
X-Mailman-Original-References: <20220416173551.fk6voaa3o25iuewm@hjp.at>
<CAPTjJmqdd4Qwrr72h4Y28dhZ_JXa9VSJFWmHXt4KfD-eNMwOTA@mail.gmail.com>
<20220417081554.wewkrvvl2xmiygsm@hjp.at>
 by: Chris Angelico - Sun, 17 Apr 2022 10:13 UTC

On Sun, 17 Apr 2022 at 18:17, Peter J. Holzer <hjp-python@hjp.at> wrote:
>
> On 2022-04-17 06:08:54 +1000, Chris Angelico wrote:
> > On Sun, 17 Apr 2022 at 03:37, Peter J. Holzer <hjp-python@hjp.at> wrote:
> > > Datetime arithmetic in the real world is typically not done in seconds,
> > > but in calendaric units: Hours, days, weeks, months, years, ...
> > > The problem is that several of these have varying lengths:
> > >
> > > * 1 minute may be 60 or 61 seconds (theoretically also 59, but that
> > > hasn't happened yet).
> > > * 1 day can be 23, 24 or 25 hours (unless you are in Troll, Antarctica,
> > > where it's even weirder).
> >
> > I think Troll still only has days that consist of 23-25 hours; the
> > weird part is that they move their clocks forward for Oslo's summer,
> > which is their winter.
>
> According to Wikipedia they switch between UTC+2 and UTC+0, so the
> switchover days would be 22 and 26 hours, respectively.

Ah, hmm. I'll have to play around with the Antarctica/Troll timezone a
bit, but it could be that they track Oslo time when only Norwegians
are there, and UTC when there are others?

In any case, there are *plenty* of bizarre cases. Whether Troll itself
is one of those or not, there certainly is no shortage of weird
changeover to be found.

> > > Subtracting a timedeltacal object from a datetime is the same, just in
> > > the opposite direction.
> > >
> > > Note that t + d - d is in general not equal to t.
> >
> > By "in general", do you mean "there will be some odd exceptions", or
> > "this is usually going to be unequal"?
>
> The former.

Okay, cool. My lengthy explanation of the question was unnecessary then :)

> > Isn't that the exact same thing as saying that t + d - d == t?
>
> No, because the overflow handling isn't reversible.
>
> > Or are you saying that, when you subtract two timestamps, you can
> > never get one of the odd exceptions that would cause problems?
>
> Yes.
>

Perfect then.

So if I've understood correctly, what you're looking for is a thing
that can be added onto a timezone-aware datetime which will have the
semantics of adding onto each component individually, and then
normalizing. That seems internally consistent, and useful. It's also a
natural continuation of Python's migration from "datetime kinda sorta
supports timezones, but only if you get a third-party package" to
"datetime actually does support timezones" (in the same way that Pike
and PostgreSQL do).

ChrisA

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor