Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

The study of non-linear physics is like the study of non-elephant biology.


devel / comp.lang.python / Standard class for time *period*?

SubjectAuthor
* Standard class for time *period*?Loris Bennett
+* Re: Standard class for time *period*?Stefan Ram
|`* Re: Standard class for time *period*?Stefan Ram
| `- Re: Standard class for time *period*?Loris Bennett
+* Re: Standard class for time *period*?rbowman
|`* Re: Standard class for time *period*?Thomas Passin
| `* Re: Standard class for time *period*?Loris Bennett
|  +* Re: Standard class for time *period*?Dennis Lee Bieber
|  |+* Re: Standard class for time *period*?Loris Bennett
|  ||+- Re: Standard class for time *period*?rbowman
|  ||`- Re: Standard class for time *period*?dn
|  |+- Re: Standard class for time *period*?Grant Edwards
|  |+- Re: Standard class for time *period*?Thomas Passin
|  |+* Re: Standard class for time *period*?Grant Edwards
|  ||`- Re: Standard class for time *period*?Stefan Ram
|  |`* Re: Standard class for time *period*?Cameron Simpson
|  | `* Re: Standard class for time *period*?Loris Bennett
|  |  +- Re: Standard class for time *period*?Thomas Passin
|  |  `- Re: Standard class for time *period*?Cameron Simpson
|  `- Aw: Re: Standard class for time *period*?Karsten Hilbert
`- Re: Standard class for time *period*?Gary Herron

1
Standard class for time *period*?

<87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: loris.bennett@fu-berlin.de (Loris Bennett)
Newsgroups: comp.lang.python
Subject: Standard class for time *period*?
Date: Mon, 27 Mar 2023 15:00:52 +0200
Organization: ZEDAT, Freie Universität Berlin
Lines: 32
Message-ID: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: news.uni-berlin.de jR6HrvLrWARHAQvj+zkIfAByYeVzlHGurMWZ59jS4TLkIj
Cancel-Lock: sha1:YBV1p5v/9AtYerFgpHEMwKyvm+U=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
 by: Loris Bennett - Mon, 27 Mar 2023 13:00 UTC

Hi,

I have been around long enough to know that, due to time-zones, daylight
saving and whatnot, time-related stuff is complicated. So even if I
think something connected with time should exist, there may well be a
very good reason why it does not.

My problem:

I need to deal with what I call a 'period', which is a span of time
limited by two dates, start and end. The period has a 'duration',
which is the elapsed time between start and end. The duration is
essentially a number of seconds, but in my context, because the
durations are usually hours or days, I would generally want to display
the duration in a format such as "dd-hh:mm:ss"

My (possibly ill-founded) expectation:

There is a standard class which encapsulates this sort of functionality.

My (possibly insufficiently researched) conclusion:

Such a standard class does not exist.

What is at fault here? My expectation or my conclusion?

Cheers,

Loris

--
This signature is currently under constuction.

Re: Standard class for time *period*?

<attempt-20230327142642@ram.dialup.fu-berlin.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Standard class for time *period*?
Date: 27 Mar 2023 13:28:44 GMT
Organization: Stefan Ram
Lines: 31
Expires: 1 Apr 2024 11:59:58 GMT
Message-ID: <attempt-20230327142642@ram.dialup.fu-berlin.de>
References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de q9Tym/FCURIhYS4WqixhYA5vQvxvEWyKN1L0sKrWJoLzRb
X-Copyright: (C) Copyright 2023 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE-1901, en-US, it, fr-FR
 by: Stefan Ram - Mon, 27 Mar 2023 13:28 UTC

"Loris Bennett" <loris.bennett@fu-berlin.de> writes:
>durations are usually hours or days, I would generally want to display
>the duration in a format such as "dd-hh:mm:ss"

Here is an attempt to do this in Python 3.9:

main.py

from datetime import datetime

format = '%Y-%m-%dT%H:%M:%S%z'
datetime_0 = datetime.strptime( '2023-03-27T14:00:52+01:00', format )
datetime_1 = datetime.strptime( '2023-03-27T14:27:23+01:00', format )

datetime_diff = datetime_1 - datetime_0

print( type( datetime_diff ))

d = datetime_diff.days
h, rem = divmod( datetime_diff.seconds, 3600 )
m, s = divmod( rem, 60 )
print( f'{d:02}-{h:02}:{m:02}:{s:02}' )

sys.stdout

<class 'datetime.timedelta'>
00-00:26:31

.

Re: Standard class for time *period*?

<formatting-20230327145104@ram.dialup.fu-berlin.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Standard class for time *period*?
Date: 27 Mar 2023 13:52:12 GMT
Organization: Stefan Ram
Lines: 26
Expires: 1 Apr 2024 11:59:58 GMT
Message-ID: <formatting-20230327145104@ram.dialup.fu-berlin.de>
References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de> <attempt-20230327142642@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de FcWAwrNqLLJbc0IHqkKN4gnWNGEc+T/0WqJ2A7Yg9WhhSc
X-Copyright: (C) Copyright 2023 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE-1901, en-US, it, fr-FR
 by: Stefan Ram - Mon, 27 Mar 2023 13:52 UTC

ram@zedat.fu-berlin.de (Stefan Ram) writes:
>d = datetime_diff.days
>h, rem = divmod( datetime_diff.seconds, 3600 )
>m, s = divmod( rem, 60 )
>print( f'{d:02}-{h:02}:{m:02}:{s:02}' )

If the default formatting is acceptable to you, you can also
print the datetime_diff in a shorter way:

main.py

from datetime import datetime

format = '%Y-%m-%dT%H:%M:%S%z'
datetime_0 = datetime.strptime( '2023-03-27T14:00:52+01:00', format )
datetime_1 = datetime.strptime( '2023-03-27T14:27:23+01:00', format )

print( datetime_1 - datetime_0 )

sys.stdout

0:26:31

. Days will also be shown if greater than zero.

Re: Standard class for time *period*?

<87fs9qjmy1.fsf@hornfels.zedat.fu-berlin.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: loris.bennett@fu-berlin.de (Loris Bennett)
Newsgroups: comp.lang.python
Subject: Re: Standard class for time *period*?
Date: Mon, 27 Mar 2023 16:20:06 +0200
Organization: ZEDAT, Freie Universität Berlin
Lines: 38
Message-ID: <87fs9qjmy1.fsf@hornfels.zedat.fu-berlin.de>
References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
<attempt-20230327142642@ram.dialup.fu-berlin.de>
<formatting-20230327145104@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: news.uni-berlin.de 1d34IThEDgGxn9CruE759AnXUiQfFPSPUP7nLoNmA5Ha9S
Cancel-Lock: sha1:USMayaLFvcpVIJSiDbVodRaPEdw=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
 by: Loris Bennett - Mon, 27 Mar 2023 14:20 UTC

ram@zedat.fu-berlin.de (Stefan Ram) writes:

> ram@zedat.fu-berlin.de (Stefan Ram) writes:
>>d = datetime_diff.days
>>h, rem = divmod( datetime_diff.seconds, 3600 )
>>m, s = divmod( rem, 60 )
>>print( f'{d:02}-{h:02}:{m:02}:{s:02}' )
>
> If the default formatting is acceptable to you, you can also
> print the datetime_diff in a shorter way:
>
> main.py
>
> from datetime import datetime
>
> format = '%Y-%m-%dT%H:%M:%S%z'
> datetime_0 = datetime.strptime( '2023-03-27T14:00:52+01:00', format )
> datetime_1 = datetime.strptime( '2023-03-27T14:27:23+01:00', format )
>
> print( datetime_1 - datetime_0 )
>
> sys.stdout
>
> 0:26:31
>
> . Days will also be shown if greater than zero.

Thanks for the examples, but I am not really interested in how to write
a bunch of code to do what I need, as I can already do that. I am
interested in whether there is a standard class for this and, if there is
not such a class, why this is the case.

Cheers,

Loris

--
This signature is currently under constuction.

Re: Standard class for time *period*?

<k8drbmFrp9rU2@mid.individual.net>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: bowman@montana.com (rbowman)
Newsgroups: comp.lang.python
Subject: Re: Standard class for time *period*?
Date: 27 Mar 2023 15:34:14 GMT
Lines: 14
Message-ID: <k8drbmFrp9rU2@mid.individual.net>
References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net 8fmiI8bmnh25t/g5l4SiqARhZVlv2nqEPwwZqpEwlOKcqWvRPS
Cancel-Lock: sha1:vEbVpmxcrVsqrQGEcPurlR16rWs=
User-Agent: Pan/0.149 (Bellevue; 4c157ba)
 by: rbowman - Mon, 27 Mar 2023 15:34 UTC

On Mon, 27 Mar 2023 15:00:52 +0200, Loris Bennett wrote:

> I need to deal with what I call a 'period', which is a span of time
> limited by two dates, start and end. The period has a 'duration',
> which is the elapsed time between start and end. The duration is
> essentially a number of seconds, but in my context, because the
> durations are usually hours or days, I would generally want to display
> the duration in a format such as "dd-hh:mm:ss"

https://www.programiz.com/python-programming/datetime

Scroll down to timedelta. If '14 days, 13:55:39' isn't good enough you'll
have to format it yourself.

Re: Standard class for time *period*?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: gherron@digipen.edu (Gary Herron)
Newsgroups: comp.lang.python
Subject: Re: Standard class for time *period*?
Date: Mon, 27 Mar 2023 09:43:02 -0700
Lines: 39
Message-ID: <mailman.2412.1679935879.20444.python-list@python.org>
References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
<022846e9-3a89-b217-4884-93c39e23048a@digipen.edu>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de 4r+MFoCAKcyqoBoIMWaHQwPekwX1nae6kuuCYLwbBnJw==
Return-Path: <gherron@digipen.edu>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="1024-bit key; unprotected key"
header.d=digipen.edu header.i=@digipen.edu header.b=hMoZkKaQ;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.033
X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'received:204': 0.05;
'datetime': 0.09; 'fault': 0.09; 'subject:class': 0.09; 'cheers,':
0.11; '(i.e.,': 0.16; '6:00': 0.16; 'daylight': 0.16;
'expectation': 0.16; 'received:10.0.0': 0.16; 'timezone': 0.16;
'wish.': 0.16; 'wrote:': 0.16; 'python': 0.16; 'to:addr:python-
list': 0.20; 'science': 0.22; 'stuff': 0.25; 'seems': 0.26;
'library': 0.26; 'received:edu': 0.26; 'computer': 0.29; 'header
:User-Agent:1': 0.30; 'am,': 0.31; 'module': 0.31; 'think': 0.32;
'end.': 0.32; 'gary': 0.32; 'objects': 0.32; 'professor': 0.32;
'received:10.0': 0.32; 'but': 0.32; 'subject:for': 0.33; 'there':
0.33; 'header:In-Reply-To:1': 0.34; 'display': 0.36; 'class':
0.37; 'two': 0.39; 'enough': 0.39; 'something': 0.40; 'want':
0.40; 'should': 0.40; 'format': 0.62; 'limited': 0.62; 'hours':
0.63; 'between': 0.63; 'duration': 0.64; 'representing': 0.64;
'well': 0.65; 'generally': 0.67; 'that,': 0.67; 'days,': 0.69;
'deal': 0.73; 'dr.': 0.77; 'period': 0.81
Authentication-Results: smtp2.digipen.edu; dkim=pass (1024-bit key;
unprotected) header.d=digipen.edu header.i=@digipen.edu header.a=rsa-sha256
header.s=mail header.b=hMoZkKaQ; dkim-atps=neutral
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=digipen.edu; s=mail;
t=1679935385; bh=/bIDkW4B51RegLSVLMmrT+9SNJdqIzsRAsQNxNwPur4=;
h=Date:Subject:To:References:From:In-Reply-To;
b=hMoZkKaQWf4aVtJ/1ifr99ElctqYCPBfTiRABHza5PJD6bQaIPo+sk6+AVnQ6iQhY
0pa1cC0QMC8Ik0amw3HgV187mfgFvWreF+TWhRWz1DysViZEsHpccJSumagM2qIUwm
IwPSL2x5XK/HQCZA/meePkBHkTYaFxmptLCymmfM=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Content-Language: en-US
In-Reply-To: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
X-Virus-Scanned: ClamAV using ClamSMTP
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: <022846e9-3a89-b217-4884-93c39e23048a@digipen.edu>
X-Mailman-Original-References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
 by: Gary Herron - Mon, 27 Mar 2023 16:43 UTC

The Python standard library module datetime seems to be what you want. 
It has objects representing date/times, and deltatimes (i.e.,
durations).  These can be timezone aware or not as you wish.

Dr. Gary Herron
Professor of Computer Science
DigiPen Institute of Technology

On 3/27/23 6:00 AM, loris.bennett@fu-berlin.de wrote:
> Hi,
>
> I have been around long enough to know that, due to time-zones, daylight
> saving and whatnot, time-related stuff is complicated. So even if I
> think something connected with time should exist, there may well be a
> very good reason why it does not.
>
> My problem:
>
> I need to deal with what I call a 'period', which is a span of time
> limited by two dates, start and end. The period has a 'duration',
> which is the elapsed time between start and end. The duration is
> essentially a number of seconds, but in my context, because the
> durations are usually hours or days, I would generally want to display
> the duration in a format such as "dd-hh:mm:ss"
>
> My (possibly ill-founded) expectation:
>
> There is a standard class which encapsulates this sort of functionality.
>
> My (possibly insufficiently researched) conclusion:
>
> Such a standard class does not exist.
>
> What is at fault here? My expectation or my conclusion?
>
> Cheers,
>
> Loris
>

Re: Standard class for time *period*?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: list1@tompassin.net (Thomas Passin)
Newsgroups: comp.lang.python
Subject: Re: Standard class for time *period*?
Date: Mon, 27 Mar 2023 13:25:22 -0400
Lines: 19
Message-ID: <mailman.2414.1679937935.20444.python-list@python.org>
References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
<k8drbmFrp9rU2@mid.individual.net>
<0354c275-33d2-f3c2-1700-56166ef5153c@tompassin.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de ZbryhyR0XhOD2fJqlnbw0ABnMMbQ9JF4WHyQ16XFUyfA==
Return-Path: <list1@tompassin.net>
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=tompassin.net header.i=@tompassin.net header.b=d6wblqw4;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.068
X-Spam-Evidence: '*H*': 0.86; '*S*': 0.00; '2023': 0.07; 'mar': 0.07;
'scroll': 0.09; 'subject:class': 0.09; 'url-ip:165/8': 0.09;
'+0200,': 0.16; 'bennett': 0.16; 'received:10.0.0': 0.16;
'received:64.90': 0.16; 'received:64.90.62': 0.16;
'received:64.90.62.162': 0.16; 'received:dreamhost.com': 0.16;
'wrote:': 0.16; 'to:addr:python-list': 0.20; "isn't": 0.27;
'header:User-Agent:1': 0.30; 'am,': 0.31; 'end.': 0.32;
'received:10.0': 0.32; 'received:mailchannels.net': 0.32;
'received:relay.mailchannels.net': 0.32; 'but': 0.32;
'subject:for': 0.33; 'header:In-Reply-To:1': 0.34; 'display':
0.36; 'mon,': 0.36; 'this.': 0.37; 'two': 0.39; 'enough': 0.39;
'want': 0.40; 'should': 0.40; 'format': 0.62; 'limited': 0.62;
'hours': 0.63; 'between': 0.63; 'down': 0.64; 'about.': 0.64;
'duration': 0.64; 'generally': 0.67; 'header:Received:6': 0.67;
'received:64': 0.67; 'exactly': 0.68; 'days,': 0.69; 'deal': 0.73;
"you'll": 0.73; 'period': 0.81
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1679937923; a=rsa-sha256;
cv=none;
b=MYCvZ3ZHo2tYjO2sqeSMaPGEn9a8WYF93APDFs76jaBCuugUMnQtYlRih6n77xo32Xtcqe
080fwo35xhcBCVVX9ny1tzQJN469g7P8t9YjIZ5pRNqD4xe0ZBY6J8yzfCt2U49QWzTybj
AY6P2ZYBWxInfO1iZzGtJBdtNaJU82CgfvTeeIsoniEy+L7dNffg0LwmhVXeFNvnkS4DRj
OOA6DLlfpByTXIDFjjWeZJu9PX8h9jQC0uckIF4QDEdl5jHm9zBHBga8W+YULGNAF8TFjn
WiXqmpukY/KxKNkSs8pwPYpqSNXZGqFmGNzWxR3vLNnXrXfEaE0giQsLRBh+yg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
d=mailchannels.net; s=arc-2022; t=1679937923;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references:dkim-signature;
bh=OGQiKeKAfF/7K0OLy73bMmYqmv7qTuQhONEfSCPYST8=;
b=5vSb7f/lsa++o0vUBDTkyhlIZX8y4GAb2JptLDumaSdCgUWpVLzkGT2EGzhGFpmxWE+iDf
HsoU2TRo9qzKTEAt8NAOr8oFj+XNlAjjVzZ+nrSQabFCS6pbEXx4aEPpa6h6282OxKIkO4
YlLp09YzgrERiRjg6lUy78uPlkqSVY0GbNhcn70HbXvcjN+1FrOqJsMuL7r2tnaeH+MmkT
gqA7KoaTilVcROogzqtyeKUv3LUoWBgIZShb07CbAnenP7iIeCuQbKCtmiPTPcfMfO7u91
64RWxVeIO9dmxwoycidoXg7ug1yrKFczm8T3+sNlVByQnCGvMdXdminEWK9u6Q==
ARC-Authentication-Results: i=1; rspamd-646fc45f85-tdhmb;
auth=pass smtp.auth=dreamhost smtp.mailfrom=list1@tompassin.net
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|tpassin@tompassin.net
X-MailChannels-Auth-Id: dreamhost
X-Suffer-Quick: 24662c5f79c4f24a_1679937923497_871319565
X-MC-Loop-Signature: 1679937923497:1813934529
X-MC-Ingress-Time: 1679937923497
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tompassin.net;
s=dreamhost; t=1679937923;
bh=OGQiKeKAfF/7K0OLy73bMmYqmv7qTuQhONEfSCPYST8=;
h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding;
b=d6wblqw4LGQ5Fb51COUYCVqDPIr7yx05k6kHyq6x8XRZGANLZ9lD8vXP9JVmcT28c
O2qKbX1IKIjZnuPnaFxobYz77JgGKD37nuSleBaNOsRECPxyIZUMINwFGw/UWVvkl1
CyickGLn1t8H/sEydKrWCcLA6ih5K+SHV1FgovOk+jG9+uFR51NoGnVS45A6aQe+/9
5pg4GtdtfeUPdN2JK2czb0PiE9prtQ5ngo03yrXjeRvHlV7Cb4lTKV2AjcTxgzg/rx
SPyAAadezmNJeEa2vsljfMOebEatResvrDVFNUUjzqnRewJaX72UDMmUq5JS+EwQdZ
V+B+f3i27H3Ng==
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Content-Language: en-US
In-Reply-To: <k8drbmFrp9rU2@mid.individual.net>
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: <0354c275-33d2-f3c2-1700-56166ef5153c@tompassin.net>
X-Mailman-Original-References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
<k8drbmFrp9rU2@mid.individual.net>
 by: Thomas Passin - Mon, 27 Mar 2023 17:25 UTC

On 3/27/2023 11:34 AM, rbowman wrote:
> On Mon, 27 Mar 2023 15:00:52 +0200, Loris Bennett wrote:
>
>
>> I need to deal with what I call a 'period', which is a span of time
>> limited by two dates, start and end. The period has a 'duration',
>> which is the elapsed time between start and end. The duration is
>> essentially a number of seconds, but in my context, because the
>> durations are usually hours or days, I would generally want to display
>> the duration in a format such as "dd-hh:mm:ss"
>
> https://www.programiz.com/python-programming/datetime
>
> Scroll down to timedelta. If '14 days, 13:55:39' isn't good enough you'll
> have to format it yourself.

I second this. timedelta should give the OP exactly what he's talking
about.

Re: Standard class for time *period*?

<87y1nhflls.fsf@debian-BULLSEYE-live-builder-AMD64>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: loris.bennett@fu-berlin.de (Loris Bennett)
Newsgroups: comp.lang.python
Subject: Re: Standard class for time *period*?
Date: Tue, 28 Mar 2023 08:14:55 +0200
Organization: ZEDAT, Freie Universität Berlin
Lines: 39
Message-ID: <87y1nhflls.fsf@debian-BULLSEYE-live-builder-AMD64>
References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
<k8drbmFrp9rU2@mid.individual.net>
<0354c275-33d2-f3c2-1700-56166ef5153c@tompassin.net>
<mailman.2414.1679937935.20444.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: news.uni-berlin.de 32yGKPFM+0kSx2nYQC/0CApkWjgLUiOV1t7kPrgJ1R4f3x
Cancel-Lock: sha1:z5wYbg0f8slD0KIxmNUTFqp03gw=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
 by: Loris Bennett - Tue, 28 Mar 2023 06:14 UTC

Thomas Passin <list1@tompassin.net> writes:

> On 3/27/2023 11:34 AM, rbowman wrote:
>> On Mon, 27 Mar 2023 15:00:52 +0200, Loris Bennett wrote:
>>
>>> I need to deal with what I call a 'period', which is a span of time
>>> limited by two dates, start and end. The period has a 'duration',
>>> which is the elapsed time between start and end. The duration is
>>> essentially a number of seconds, but in my context, because the
>>> durations are usually hours or days, I would generally want to display
>>> the duration in a format such as "dd-hh:mm:ss"
>> https://www.programiz.com/python-programming/datetime
>> Scroll down to timedelta. If '14 days, 13:55:39' isn't good enough
>> you'll
>> have to format it yourself.
>
> I second this. timedelta should give the OP exactly what he's talking
> about.

No, it doesn't. I already know about timedelta. I must have explained
the issue badly, because everyone seems to be fixating on the
formatting, which is not a problem and is incidental to what I am really
interested in, namely:

1. Is there a standard class for a 'period', i.e. length of time
specified by a start point and an end point? The start and end
points could obviously be datetimes and the difference a timedelta,
but the period '2022-03-01 00:00 to 2022-03-02 00:00' would be
different to '2023-03-01 00:00 to 2023-03-02 00:00' even if the
*duration* of both periods is the same.

2. If such a standard class doesn't exist, why does it not exist?

Cheers,

Loris

--
This signature is currently under constuction.

Re: Standard class for time *period*?

<bfl52i9t8peoep2mtf5bivis5b2be4aso2@4ax.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 28 Mar 2023 12:05:39 +0000
From: wlfraed@ix.netcom.com (Dennis Lee Bieber)
Newsgroups: comp.lang.python
Subject: Re: Standard class for time *period*?
Date: Tue, 28 Mar 2023 08:05:40 -0400
Organization: IISS Elusive Unicorn
Message-ID: <bfl52i9t8peoep2mtf5bivis5b2be4aso2@4ax.com>
References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de> <k8drbmFrp9rU2@mid.individual.net> <0354c275-33d2-f3c2-1700-56166ef5153c@tompassin.net> <mailman.2414.1679937935.20444.python-list@python.org> <87y1nhflls.fsf@debian-BULLSEYE-live-builder-AMD64>
User-Agent: ForteAgent/8.00.32.1272
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 28
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-lVq9XevHiTuactZZ+unS1Fz9y7/UHh8O2V+MiGMzHwUtxbhJy0rdOeJyA2HpysI0N+5xBpgYoph7PMi!CzXBtd0/wdZmIebRfLMLUlF85bdN4c+6QtNBEjmWDuvoHMbYlOS4j1+cEdIZOsH7YWBJPeYP
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Dennis Lee Bieber - Tue, 28 Mar 2023 12:05 UTC

On Tue, 28 Mar 2023 08:14:55 +0200, "Loris Bennett"
<loris.bennett@fu-berlin.de> declaimed the following:

>
>No, it doesn't. I already know about timedelta. I must have explained
>the issue badly, because everyone seems to be fixating on the
>formatting, which is not a problem and is incidental to what I am really
>interested in, namely:
>
>1. Is there a standard class for a 'period', i.e. length of time
> specified by a start point and an end point? The start and end
> points could obviously be datetimes and the difference a timedelta,
> but the period '2022-03-01 00:00 to 2022-03-02 00:00' would be
> different to '2023-03-01 00:00 to 2023-03-02 00:00' even if the
> *duration* of both periods is the same.
>
>2. If such a standard class doesn't exist, why does it not exist?
>

So far, you seem to be the only person who has ever asked for a single
entity incorporating an EPOCH (datetime.datetime) + a DURATION
(datetime.timedelta). You are asking for two durations of the same length
to be considered different if they were computed from different "zero"
references (epochs). I don't think I've ever encountered an application
that doesn't use a single epoch (possibly per run) with all internal
computations using a timedelta FROM THAT EPOCH! (The exception may have
been computing star atlases during the conversion from B1900 to J2000
reference frames.)

Re: Standard class for time *period*?

<87a5zxf2bx.fsf@debian-BULLSEYE-live-builder-AMD64>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: loris.bennett@fu-berlin.de (Loris Bennett)
Newsgroups: comp.lang.python
Subject: Re: Standard class for time *period*?
Date: Tue, 28 Mar 2023 15:11:14 +0200
Organization: ZEDAT, Freie Universität Berlin
Lines: 46
Message-ID: <87a5zxf2bx.fsf@debian-BULLSEYE-live-builder-AMD64>
References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
<k8drbmFrp9rU2@mid.individual.net>
<0354c275-33d2-f3c2-1700-56166ef5153c@tompassin.net>
<mailman.2414.1679937935.20444.python-list@python.org>
<87y1nhflls.fsf@debian-BULLSEYE-live-builder-AMD64>
<bfl52i9t8peoep2mtf5bivis5b2be4aso2@4ax.com>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: news.uni-berlin.de AfiNDGbuQn24zlS9T1tp7AY7phMJx8zSkwzCvKOoZVwtEa
Cancel-Lock: sha1:C4mP74g8lDWmMIIU7idKWL9D3s0=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
 by: Loris Bennett - Tue, 28 Mar 2023 13:11 UTC

Dennis Lee Bieber <wlfraed@ix.netcom.com> writes:

> On Tue, 28 Mar 2023 08:14:55 +0200, "Loris Bennett"
> <loris.bennett@fu-berlin.de> declaimed the following:
>
>>
>>No, it doesn't. I already know about timedelta. I must have explained
>>the issue badly, because everyone seems to be fixating on the
>>formatting, which is not a problem and is incidental to what I am really
>>interested in, namely:
>>
>>1. Is there a standard class for a 'period', i.e. length of time
>> specified by a start point and an end point? The start and end
>> points could obviously be datetimes and the difference a timedelta,
>> but the period '2022-03-01 00:00 to 2022-03-02 00:00' would be
>> different to '2023-03-01 00:00 to 2023-03-02 00:00' even if the
>> *duration* of both periods is the same.
>>
>>2. If such a standard class doesn't exist, why does it not exist?
>>
>
> So far, you seem to be the only person who has ever asked for a single
> entity incorporating an EPOCH (datetime.datetime) + a DURATION
> (datetime.timedelta). You are asking for two durations of the same length
> to be considered different if they were computed from different "zero"
> references (epochs).

I thought I was asking for two periods of the same duration to be
considered different, if they have different starting points :-)

> I don't think I've ever encountered an application
> that doesn't use a single epoch (possibly per run) with all internal
> computations using a timedelta FROM THAT EPOCH! (The exception may have
> been computing star atlases during the conversion from B1900 to J2000
> reference frames.)

But even if I have a single epoch, January 2022 is obviously different
to January 2023, even thought the duration might be the same. I am just
surprised that there is no standard Period class, with which I could
create objects and then be able to sort, check for identity, equality of
length, amount of overlap, etc. I suppose people just use a
datetime.datetime pair, as I have been doing so far, and tack on just
the specific bit of functionality they need.

--
This signature is currently under constuction.

Re: Standard class for time *period*?

<k8gb74F97l8U1@mid.individual.net>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: bowman@montana.com (rbowman)
Newsgroups: comp.lang.python
Subject: Re: Standard class for time *period*?
Date: 28 Mar 2023 14:17:08 GMT
Lines: 12
Message-ID: <k8gb74F97l8U1@mid.individual.net>
References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
<k8drbmFrp9rU2@mid.individual.net>
<0354c275-33d2-f3c2-1700-56166ef5153c@tompassin.net>
<mailman.2414.1679937935.20444.python-list@python.org>
<87y1nhflls.fsf@debian-BULLSEYE-live-builder-AMD64>
<bfl52i9t8peoep2mtf5bivis5b2be4aso2@4ax.com>
<87a5zxf2bx.fsf@debian-BULLSEYE-live-builder-AMD64>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net WGYb+kjW/B1RowAdpw+t5gI5diLP+GNQeYI3UmP+xmz07YgXhW
Cancel-Lock: sha1:hFHfKQUz/O7cwT0Arx2OXAEdPUQ=
User-Agent: Pan/0.149 (Bellevue; 4c157ba)
 by: rbowman - Tue, 28 Mar 2023 14:17 UTC

On Tue, 28 Mar 2023 15:11:14 +0200, Loris Bennett wrote:

> But even if I have a single epoch, January 2022 is obviously different
> to January 2023, even thought the duration might be the same. I am just
> surprised that there is no standard Period class, with which I could
> create objects and then be able to sort, check for identity, equality of
> length, amount of overlap, etc. I suppose people just use a
> datetime.datetime pair, as I have been doing so far, and tack on just
> the specific bit of functionality they need.

It's called Unix time... Convert the seconds into whatever you want.

Aw: Re: Standard class for time *period*?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: Karsten.Hilbert@gmx.net (Karsten Hilbert)
Newsgroups: comp.lang.python
Subject: Aw: Re: Standard class for time *period*?
Date: Tue, 28 Mar 2023 17:42:23 +0200
Lines: 28
Message-ID: <mailman.2425.1680018162.20444.python-list@python.org>
References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
<k8drbmFrp9rU2@mid.individual.net>
<0354c275-33d2-f3c2-1700-56166ef5153c@tompassin.net>
<mailman.2414.1679937935.20444.python-list@python.org>
<87y1nhflls.fsf@debian-BULLSEYE-live-builder-AMD64>
<trinity-0d54ca50-effd-4506-9314-9297da2053d6-1680018143398@3c-app-gmx-bap72>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de KybNf0tjmfoD9bmnqtaJCQmEPjY9/dPBGX99jCZi0rfw==
Return-Path: <Karsten.Hilbert@gmx.net>
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=gmx.net header.i=karsten.hilbert@gmx.net
header.b=FQSSYvtl; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.018
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'def': 0.04; 'library.':
0.05; 'received:212.227': 0.07; 'cc:addr:python-list': 0.09;
'karsten': 0.09; 'obviously': 0.09; 'subject:class': 0.09; 'cc:no
real name:2**0': 0.14; 'namely:': 0.16; 'received:(via http)':
0.16; 'problem': 0.16; 'cc:addr:python.org': 0.20; 'issue': 0.21;
'i.e.': 0.22; 'skip:_ 10': 0.22; 'cc:2**0': 0.25; 'seems': 0.26;
'everyone': 0.32; 'specified': 0.32; 'but': 0.32; 'subject:for':
0.33; 'there': 0.33; 'header:In-Reply-To:1': 0.34; 'really': 0.37;
'class': 0.37; 'could': 0.38; 'both': 0.40; 'in,': 0.60;
'received:212': 0.62; 'explained': 0.64; 'received:217': 0.67;
'interested': 0.68; 'within': 0.69; 'period': 0.81; 'points':
0.84; 'constraints': 0.84; 'periods': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417;
t=1680018143; i=karsten.hilbert@gmx.net;
bh=buy6EzfnvIBVAZDulrIyX891xAnTQN7VWh9MAcv47cI=;
h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References;
b=FQSSYvtldetT+MSbZKFO7UKlk50HNAMs8WPeJCr04muhux0ZIK06atr26K4x59P0D
sz6dryLQLQCYPdRzKdoqAMhJi97LAYKhQ/6LWu6GzcS+pg4+ke6YcVuWpIMBHmDv14
2mV9LnwPr5Ms8z57lnb1hxj9dG3V1rqZ8WBaL05WVwZYalYU6CC4jj/5OR/AC6Pvu4
FZcRaKbr+eKeOjQEVYCbWxGMiY/uEgHM+sneM3xuf22PgwZVX3m6oCszwEjHHU43Q1
qyp7kBfHzxsNHzY5jujDj0aEEuWkMsc2SgCSXCC9liFLlQ9UeRa4NUWtASZqACIa6b
WzdjTQdWSfJGw==
X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a
Importance: normal
Sensitivity: Normal
In-Reply-To: <87y1nhflls.fsf@debian-BULLSEYE-live-builder-AMD64>
X-UI-Message-Type: mail
X-Priority: 3
X-Provags-ID: V03:K1:bBOJtmg/WFF9w1U+dOuAO+//sA+cimxR0M9Npg2WIhTN/hPOMUJV45GY9MFAuHs1bBFG8
MMFpD89azJ5GLiBVea+/tjcl8YA5VX8fu4zWbexmXLmaWh1ozjBlc3XGDEu25iPjK7xkrMAvA8bw
rzswUj+EXwp0XFgDkWlJPUVnFR7nOomCWnWPtPs1qZB6sn3rpGH/mgWazm9bsDLvBDrvjBf4F0y4
3Fg228+RwlGAe7RAQ0PYoWZ4aqV+AeDgtzpZnXIAzQg9oqv3qzyoYTuTHd3kJ5YMPU3X8IGO0ZS5
OQ=
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:Ta49WZclFSo=;ofZ437+YNoSY71M5UNB/EBP3CjW
KeC5PC4XVaP4RN8CvLEML51ovU1iocy8JI/eCrjz6bBgR6+i77lbkDVt5KkNoRU+72bm+60bp
rMm2Wx4ERQDX5oRyLOvEnd2s/YL1SsR6/cseS0g9lwqO/tXR8WFWDmCiroW1TvUY0Eq4yqiS/
WY7kUTJVCJXDdBspIWk5mEVjZFVw56bnQVfyVgHEffeCPESOlzQWoiELhTL0sK9c/DlL1Uyfe
yQh0ac15gBQ6/qP9DyU7KsyBH17Ir3YRorxOpCVsIO2jGNHGE/NyfS+YxipRwFt5obW29RmVo
foou73WShXX0qTr/hNvnMvpmO5FA/jAmiS5IBR8PvZAD2wBxQw5CQE3Op8TlCAhDpck9dekRF
VNlFghDw3oIrtcOQpM2W1x5sjevEIBnDELQ92WIkQmLizKn5BdFGGHj0zuGdHhm/OnKZLHndH
YhbqgXcVWT+nHX1rXvfKgEZR0I7K0ObVQsPkiyvtsnYtPg4Z1BXyWUnKzeGSwC9rD9Ecp11c2
hQ0qiarV3xF5m4izXOTpEMn03IqLLAnvKboOqcXvE61b9YMQUTrEtltW3SbNUoaj3VVmMD/IA
tFDoKBBUjpzzrjheScuQwNeHWRK4gBJlvaCcFYgfjGuB062PHJzyl+R3I/K3HcaOl2EkOhe5p
n/+iEqKIgFY7tfX6a8ADo6DwruNW7AK5RSoK6BCAssQEinWfWUxK6bhxVSsbtJsHtQaKKjAPi
coD73igmLEPYiD0Enan/Cw5uTF2HPZ6CWh42qDPmDl29gm0ktPpakJBqRKroGMnWlXMHsavgZ
rwbY7JvsfCpuA0vfJylTgXyw==
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: <trinity-0d54ca50-effd-4506-9314-9297da2053d6-1680018143398@3c-app-gmx-bap72>
X-Mailman-Original-References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
<k8drbmFrp9rU2@mid.individual.net>
<0354c275-33d2-f3c2-1700-56166ef5153c@tompassin.net>
<mailman.2414.1679937935.20444.python-list@python.org>
<87y1nhflls.fsf@debian-BULLSEYE-live-builder-AMD64>
 by: Karsten Hilbert - Tue, 28 Mar 2023 15:42 UTC

> No, it doesn't. I already know about timedelta. I must have explained
> the issue badly, because everyone seems to be fixating on the
> formatting, which is not a problem and is incidental to what I am really
> interested in, namely:
>
> 1. Is there a standard class for a 'period', i.e. length of time
> specified by a start point and an end point? The start and end
> points could obviously be datetimes and the difference a timedelta,
> but the period '2022-03-01 00:00 to 2022-03-02 00:00' would be
> different to '2023-03-01 00:00 to 2023-03-02 00:00' even if the
> *duration* of both periods is the same.

Not that I know, within the constraints of the standard library.

However:

class CalendarPeriod:
def __init__(self, start, end):
self.start = start
self.end = end

?

For this to be *useful* more needs need to be explained. Until then - YAGNI.

Karsten

Re: Standard class for time *period*?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: grant.b.edwards@gmail.com (Grant Edwards)
Newsgroups: comp.lang.python
Subject: Re: Standard class for time *period*?
Date: Tue, 28 Mar 2023 09:13:02 -0700 (PDT)
Lines: 16
Message-ID: <mailman.2427.1680019986.20444.python-list@python.org>
References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
<k8drbmFrp9rU2@mid.individual.net>
<0354c275-33d2-f3c2-1700-56166ef5153c@tompassin.net>
<mailman.2414.1679937935.20444.python-list@python.org>
<87y1nhflls.fsf@debian-BULLSEYE-live-builder-AMD64>
<bfl52i9t8peoep2mtf5bivis5b2be4aso2@4ax.com>
<6423120e.050a0220.5bfa6.d186@mx.google.com>
X-Trace: news.uni-berlin.de 5k7BoXVPgVg8nKDje7+wMgWm0FeCACAJwos+eNL0I+Pg==
Return-Path: <grant.b.edwards@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=YJncLcuz;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.041
X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'class,': 0.05;
'received:209.85.166.180': 0.09; 'subject:class': 0.09; 'far,':
0.16; 'from:addr:grant.b.edwards': 0.16; 'from:name:grant
edwards': 0.16; 'tuple': 0.16; 'wrote:': 0.16; 'grant': 0.17;
'to:addr:python-list': 0.20; 'lines': 0.23; 'seems': 0.26;
'asked': 0.29; 'header:User-Agent:1': 0.30; 'seem': 0.31;
'objects': 0.32; 'but': 0.32; 'subject:for': 0.33; 'same': 0.34;
'received:google.com': 0.34; 'received:209.85.166': 0.35;
'from:addr:gmail.com': 0.35; 'really': 0.37; "it's": 0.37;
'received:209.85': 0.37; 'received:209': 0.39; 'two': 0.39;
'single': 0.39; 'ever': 0.63; 'duration': 0.64; 'six': 0.65;
'obvious': 0.69; 'color.': 0.84; 'dozen': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112; t=1680019983;
h=to:user-agent:references:subject:from:date:message-id:from:to:cc
:subject:date:message-id:reply-to;
bh=/OsUBuXiEc2zj/xfp7cRt6oCqI5kb/cE+rcgQjjNpcE=;
b=YJncLcuzjibgEiwVfn6QdZCHmYddszJ6npbh8hirARV372X0aBGXnZWA/ckyUed7mc
z5mjNxaYnCoGBIOONNLleCNiv1uYnhB1nwJ1Rhu5ESZyxIbPQZPQjmBN47cIW/PC9yLa
M4Op6pW/eF3ONHfn15tA9u7g2JrPbajWU4x7VUXzQTuG5+eEro6Hn+/ANKJ8qfRvl5a4
jC9yxGAmnxOPdOhMOs56l3e05t4rWle1H3ndzwZMzLGau9V+AcRYikS+v5hruBQUa58l
qxrTJxEWns4lA0eW1dtMzGlbMRnn6tJPjviQAOHwIklTiydiGO3qO+G/mfln//Ntxkq2
qqgA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112; t=1680019983;
h=to:user-agent:references:subject:from:date:message-id
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=/OsUBuXiEc2zj/xfp7cRt6oCqI5kb/cE+rcgQjjNpcE=;
b=AsnF0FLtBYjo3b1AvLGe4hNvw9AGFQUOyzCCnwDGo6M0uVQpIoGZV0bA892uPqDovu
5b8ZqNUuDDHOPf7fYdMj94NG6YDyKt+LmCjcHz0LQ8ZkkGFV2DOr3SQjwdwloe8y8oe3
lxzps8SKRw4cR0n5Z/AAOq0IVrpONmZRVJi448e2EBSRB5cqnN0qk8LkJW6BoDT4LJ8E
zqDxagIDKe0CmI02Rmwkx0TAjEWOaTD4gAl7BHPJFxh9Tr4AFj2qDkAR1BZzM/dlcUYL
prskvxDKwTJpePC1UUF/S4MVCzAgJKm9h4XTx1hd4z6oF/IVKsInRhMGRtRvYA8m8eQ9
lUOQ==
X-Gm-Message-State: AAQBX9fjTrzDKepz9oGnFdW47myY0rs/qTgqcjQPPTiCKQnBrcamaqh5
EJ172D94t7o+brM1toUEN9LzLWoPPY8=
X-Google-Smtp-Source: AKy350YiOsmvu9gVo5nzN8pIg1k1qFU8vb+DYrJcaHr3O5im3ZY5fCINBn+DeQQIH7h6oWDsM8LQkA==
X-Received: by 2002:a92:cf08:0:b0:317:d91d:93b with SMTP id
c8-20020a92cf08000000b00317d91d093bmr12915373ilo.13.1680019982963;
Tue, 28 Mar 2023 09:13:02 -0700 (PDT)
User-Agent: slrn/1.0.3 (Linux)
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: <6423120e.050a0220.5bfa6.d186@mx.google.com>
X-Mailman-Original-References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
<k8drbmFrp9rU2@mid.individual.net>
<0354c275-33d2-f3c2-1700-56166ef5153c@tompassin.net>
<mailman.2414.1679937935.20444.python-list@python.org>
<87y1nhflls.fsf@debian-BULLSEYE-live-builder-AMD64>
<bfl52i9t8peoep2mtf5bivis5b2be4aso2@4ax.com>
 by: Grant Edwards - Tue, 28 Mar 2023 16:13 UTC

On 2023-03-28, Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote:

> So far, you seem to be the only person who has ever asked for a
> single entity incorporating an EPOCH (datetime.datetime) + a
> DURATION (datetime.timedelta).

It seems to me that tuple of two timdate objects (start,end) is the
more obvious representation, but it's six of one and a horse of the
same color.

If one really needs it to be a class, then it woulnd't be much more
than a dozen or two lines of code...

--
Grant

Re: Standard class for time *period*?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: list1@tompassin.net (Thomas Passin)
Newsgroups: comp.lang.python
Subject: Re: Standard class for time *period*?
Date: Tue, 28 Mar 2023 12:29:26 -0400
Lines: 34
Message-ID: <mailman.2429.1680020980.20444.python-list@python.org>
References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
<k8drbmFrp9rU2@mid.individual.net>
<0354c275-33d2-f3c2-1700-56166ef5153c@tompassin.net>
<mailman.2414.1679937935.20444.python-list@python.org>
<87y1nhflls.fsf@debian-BULLSEYE-live-builder-AMD64>
<bfl52i9t8peoep2mtf5bivis5b2be4aso2@4ax.com>
<6423120e.050a0220.5bfa6.d186@mx.google.com>
<5a5a2d97-baab-9960-bfda-b352136e4f7c@tompassin.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de MkpXaPC0avOUzAtAGLX3RQ0DZO54gm9HrKCntXva0yuA==
Return-Path: <list1@tompassin.net>
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=tompassin.net header.i=@tompassin.net header.b=zjj3g0os;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.029
X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; '2022': 0.05; 'class,':
0.05; 'example.': 0.09; 'obviously': 0.09; 'subject:class': 0.09;
'that.': 0.15; '"but': 0.16; 'far,': 0.16; 'received:10.0.0':
0.16; 'received:64.90': 0.16; 'received:64.90.62': 0.16;
'received:64.90.62.162': 0.16; 'received:dreamhost.com': 0.16;
'sort,': 0.16; 'sorting,': 0.16; 'things,': 0.16; 'think.': 0.16;
'tuple': 0.16; 'wrote:': 0.16; 'grant': 0.17; 'implement': 0.19;
'pm,': 0.19; 'to:addr:python-list': 0.20; 'lines': 0.23; 'seems':
0.26; 'bit': 0.27; 'done': 0.28; 'sense': 0.28; 'asked': 0.29;
'header:User-Agent:1': 0.30; 'seem': 0.31; 'think': 0.32;
'carefully': 0.32; 'objects': 0.32; 'received:10.0': 0.32;
'received:mailchannels.net': 0.32;
'received:relay.mailchannels.net': 0.32; 'but': 0.32;
'subject:for': 0.33; 'there': 0.33; 'able': 0.34; 'same': 0.34;
'header:In-Reply-To:1': 0.34; 'people': 0.36; 'those': 0.36;
'really': 0.37; "it's": 0.37; 'class': 0.37; 'hard': 0.37;
'could': 0.38; 'two': 0.39; 'single': 0.39; 'use': 0.39;
'methods': 0.39; 'on.': 0.39; 'method': 0.61; 'ever': 0.63;
'complete': 0.64; 'duration': 0.64; 'six': 0.65;
'header:Received:6': 0.67; 'received:64': 0.67; 'exactly': 0.68;
'obvious': 0.69; 'january': 0.71; 'period': 0.81; 'color.': 0.84;
'dozen': 0.84; 'figuring': 0.84; 'identity,': 0.84; 'lines,':
0.84; 'ordering': 0.84; 'surprised': 0.84
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1680020967; a=rsa-sha256;
cv=none;
b=dK4bhB66zcruZuUVr8ACLxIOhnVtSX82OfV+g1eKnf4Z6PtCWxKN1pur2m6Q6AcaZ9/6PK
q7zUnIgsyw4iMxCO7Ce+44L1d4fMUYjocz4taF1emH8pYi3JHUn3fbLJp4hpTEb5Hsb/L0
Jxb8RuwvaJT3rsUsyUz4748GlrTrq/NptUwH09b3FZViWYwU5e74QFDQ6Gse9odELs2J7U
i5oFPspLyJPBVyhxJoasMPKBabZlPCY+nYMdumAet9zt5Ah0SDQcKeP7FEXFoayR+8L34V
qsfR+T+f366oBYmh7q0ZQtnXO3who27GWI07IJ7Ik388rqeK+H58T6N2jH3r+w==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
d=mailchannels.net; s=arc-2022; t=1680020967;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references:dkim-signature;
bh=wTbNGSGf7fa3cOLS/1T+1bBoDJY08KOFBOCDHz/qEc8=;
b=FZkgRGtqprSA6Zx1RYSdoyC32Xpk9gou9yzDredSchSUKkEy1YCTOzxCs/mJts89lMoqnP
SmURn++jTuorZeLTGTE45rJTZhARV3Qv0sFEysHMWk42V/GimcUhZsjjtRUaTbxvg2h/e6
YC8AAMN4TQi9tqAoAsTKVknv9hZUAJ5x8rGB8LH6gwNFsb2VN70dChZpfNRciEKLVTorvm
UNuqGQdAkulOcRUdZHJQNUtZMgEGqn7V9q1abdt9YL0rCt7kQljEjUUvJ59CFZy4QWkLjB
uSo0g0pqsHG979A0mYYWRuLdu1YRlBO0WJQxrlVWhm5Q8V50te/93lnSC2e9dw==
ARC-Authentication-Results: i=1; rspamd-f7c6fbdc6-wdp8n;
auth=pass smtp.auth=dreamhost smtp.mailfrom=list1@tompassin.net
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|tpassin@tompassin.net
X-MailChannels-Auth-Id: dreamhost
X-Stop-Imminent: 591d57646c937ac0_1680020967757_1218219840
X-MC-Loop-Signature: 1680020967757:1111189014
X-MC-Ingress-Time: 1680020967756
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tompassin.net;
s=dreamhost; t=1680020967;
bh=wTbNGSGf7fa3cOLS/1T+1bBoDJY08KOFBOCDHz/qEc8=;
h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding;
b=zjj3g0os+AA/ZIGNnrC4HehccJMLS+2pgjuoWLJT+Jk90ei3lV+73qYl7YUaM6I4O
uLvmJFE2FV5MGpcfBBH3C/Yer8juO/CnxHMLOY+wh41EoJ6n79W/t7N5gF8c/cNind
iGka/s2cx1ocCEF5vN0rZvXZPlrqp8kmg+4kUd7xLptuVKPF1Ws5erDcwa6ppT/77q
fOp7te6DJidAjo2yOXjBMfqiZD8zAPBLX7FSXZRW+8AaottZFEiJR+saMIGoWk+Cw1
/doVl+64vT1LPFQ3i2XYU4gbO3VKajwkKhunvBNH/BXcVg8KDkrwrOiloAQvA1vkbt
CUb2dMFe8LlcA==
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Content-Language: en-US
In-Reply-To: <6423120e.050a0220.5bfa6.d186@mx.google.com>
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: <5a5a2d97-baab-9960-bfda-b352136e4f7c@tompassin.net>
X-Mailman-Original-References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
<k8drbmFrp9rU2@mid.individual.net>
<0354c275-33d2-f3c2-1700-56166ef5153c@tompassin.net>
<mailman.2414.1679937935.20444.python-list@python.org>
<87y1nhflls.fsf@debian-BULLSEYE-live-builder-AMD64>
<bfl52i9t8peoep2mtf5bivis5b2be4aso2@4ax.com>
<6423120e.050a0220.5bfa6.d186@mx.google.com>
 by: Thomas Passin - Tue, 28 Mar 2023 16:29 UTC

On 3/28/2023 12:13 PM, Grant Edwards wrote:
> On 2023-03-28, Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote:
>
>> So far, you seem to be the only person who has ever asked for a
>> single entity incorporating an EPOCH (datetime.datetime) + a
>> DURATION (datetime.timedelta).
>
> It seems to me that tuple of two timdate objects (start,end) is the
> more obvious representation, but it's six of one and a horse of the
> same color.
>
> If one really needs it to be a class, then it woulnd't be much more
> than a dozen or two lines of code...

I think it would be more than that. The OP said

"But even if I have a single epoch, January 2022 is obviously different
to January 2023, even thought the duration might be the same. I am just
surprised that there is no standard Period class, with which I could
create objects and then be able to sort, check for identity, equality of
length, amount of overlap, etc. I suppose people just use a
datetime.datetime pair, as I have been doing so far, and tack on just
the specific bit of functionality they need."

A class could be devised to have methods to do those things, but it
would take some thought to be sure if they all made sense. Take
sorting, for example. Are two "Periods" really comparable? Can we have
complete ordering here? "Identity" too would have to be carefully
defined, and then a __eq__ method could be implemented. And so on.

It would take more than 10 or 20 lines, I would think. But the hard
work of figuring out exactly what is wanted and what even makes sense to
implement needs to be done first.

Re: Standard class for time *period*?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: grant.b.edwards@gmail.com (Grant Edwards)
Newsgroups: comp.lang.python
Subject: Re: Standard class for time *period*?
Date: Tue, 28 Mar 2023 09:49:32 -0700 (PDT)
Lines: 28
Message-ID: <mailman.2430.1680022175.20444.python-list@python.org>
References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
<k8drbmFrp9rU2@mid.individual.net>
<0354c275-33d2-f3c2-1700-56166ef5153c@tompassin.net>
<mailman.2414.1679937935.20444.python-list@python.org>
<87y1nhflls.fsf@debian-BULLSEYE-live-builder-AMD64>
<bfl52i9t8peoep2mtf5bivis5b2be4aso2@4ax.com>
<6423120e.050a0220.5bfa6.d186@mx.google.com>
<5a5a2d97-baab-9960-bfda-b352136e4f7c@tompassin.net>
<64231a9c.020a0220.22fa8.2d2c@mx.google.com>
X-Trace: news.uni-berlin.de UlB7jKGckJtQ2ibA1aEvSAcknwx92DXtDbF49IcjK3rA==
Return-Path: <grant.b.edwards@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=Fn8XhZg1;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.082
X-Spam-Evidence: '*H*': 0.84; '*S*': 0.00; 'class,': 0.05;
'subject:class': 0.09; 'that.': 0.15; 'far,': 0.16;
'from:addr:grant.b.edwards': 0.16; 'from:name:grant edwards':
0.16; 'mentioned,': 0.16; 'operations,': 0.16; 'right.': 0.16;
'tuple': 0.16; 'wrote:': 0.16; 'grant': 0.17; "can't": 0.17;
'pm,': 0.19; 'to:addr:python-list': 0.20; 'lines': 0.23; 'seems':
0.26; 'do,': 0.26; 'bit': 0.27; '>>>': 0.28; 'asked': 0.29;
'header:User-Agent:1': 0.30; 'seem': 0.31; 'think': 0.32;
"doesn't": 0.32; 'objects': 0.32; 'but': 0.32; 'subject:for':
0.33; 'there': 0.33; 'same': 0.34; 'received:google.com': 0.34;
'received:209.85.166': 0.35; 'from:addr:gmail.com': 0.35; 'those':
0.36; 'couple': 0.37; 'really': 0.37; "it's": 0.37;
'received:209.85': 0.37; 'class': 0.37; 'hard': 0.37;
'received:209': 0.39; 'two': 0.39; 'single': 0.39; "there's":
0.61; 'ever': 0.63; 'definition': 0.64; 'duration': 0.64; 'six':
0.65; 'operations': 0.68; 'obvious': 0.69; 'supposed': 0.76;
'more.': 0.82; 'color.': 0.84; 'dozen': 0.84; 'forgotten': 0.84;
'says,': 0.84; 'line,': 0.93
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112; t=1680022173;
h=to:user-agent:references:subject:from:date:message-id:from:to:cc
:subject:date:message-id:reply-to;
bh=03VtIT7WD6UyZIgxyYdic6tyhG0CJ25W6WGU2N+PxoQ=;
b=Fn8XhZg1oFmi+Z0msvzg8LyhzewODUz4jH4Q3BKlZfWU727Zon8+TajFDmn7/nS5Ok
bbB2uDL8s9e1cYk/jecA++024TzvTIhmZUEQejDpovPBtL53PYWQ4jps52SrCA8GRT+B
1dAKoX+M3qmyfdgkkNBsuS8Y10FK67Ca34W016WsSnFM2RX4kBeLrJuI2tGmwrAv2Kua
vMl6Ir0rKmSxIlzf1iOap0q5q7kXVof8A2FyteWW/ZhvL0wERL+iYqMHKoVoODjbX17Z
4SyeO4O/Tqkuvur3U7byfFn3UTUEsP4ziWWajfa5+oZcxfT7KigzSQi6UqUruFyQY6Bs
lwag==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112; t=1680022173;
h=to:user-agent:references:subject:from:date:message-id
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=03VtIT7WD6UyZIgxyYdic6tyhG0CJ25W6WGU2N+PxoQ=;
b=0Pqf5cZNC0lD+OcoNTMgkEt3EKDowVY5sV+UNKcuc+nxPbEPkT7Es+QcZvwW40L6sa
NbXM85qrUit/ypnqk33DSrsz+If2gQlj345qki8GzstO2CCbibPcF/dLhv0K8JCngvND
hoJ2a7w2pPAK2jj+ys/SGI+Ug+9/jJCMqtHf/art5MS8hEv2/0lbZc/QNe3elXvuwmXN
x05otXD5bT9w4WaODY3Ujvy0WbINmtsOlXFKUvnF87tC/18wROOVSPZ4HhIbsMR2vbjE
0HXcbWA0rAgGIwSdxpoLvEZ5NnjFR1BTcyQ1zWc7ifATSZNew/d9r7MNx0cuxIanfq/P
KJzQ==
X-Gm-Message-State: AO0yUKWxG6mFhifQCE/0CFdwGybV8reeSxutwn3LDMFBfgUJ0Nh3gTtU
fHoP/KvkrapdAoJfYO564+Wq5J01Vbc=
X-Google-Smtp-Source: AK7set+d7LbPYN1sIBxrUetrsUsXUinl/zPUWr7vMS+CBNRDocWOnQqrboaoc6h7NPJjTJrVIYMSdQ==
X-Received: by 2002:a5e:8f4c:0:b0:74f:b453:b334 with SMTP id
x12-20020a5e8f4c000000b0074fb453b334mr12571239iop.18.1680022172884;
Tue, 28 Mar 2023 09:49:32 -0700 (PDT)
User-Agent: slrn/1.0.3 (Linux)
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: <64231a9c.020a0220.22fa8.2d2c@mx.google.com>
X-Mailman-Original-References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
<k8drbmFrp9rU2@mid.individual.net>
<0354c275-33d2-f3c2-1700-56166ef5153c@tompassin.net>
<mailman.2414.1679937935.20444.python-list@python.org>
<87y1nhflls.fsf@debian-BULLSEYE-live-builder-AMD64>
<bfl52i9t8peoep2mtf5bivis5b2be4aso2@4ax.com>
<6423120e.050a0220.5bfa6.d186@mx.google.com>
<5a5a2d97-baab-9960-bfda-b352136e4f7c@tompassin.net>
 by: Grant Edwards - Tue, 28 Mar 2023 16:49 UTC

On 2023-03-28, Thomas Passin <list1@tompassin.net> wrote:
> On 3/28/2023 12:13 PM, Grant Edwards wrote:
>> On 2023-03-28, Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote:
>>
>>> So far, you seem to be the only person who has ever asked for a
>>> single entity incorporating an EPOCH (datetime.datetime) + a
>>> DURATION (datetime.timedelta).
>>
>> It seems to me that tuple of two timdate objects (start,end) is the
>> more obvious representation, but it's six of one and a horse of the
>> same color.
>>
>> If one really needs it to be a class, then it woulnd't be much more
>> than a dozen or two lines of code...
>
> I think it would be more than that. The OP said

You're right. I had forgotten about a few of the operations mentioned,
so it might take a bit more than a couple dozen line, but not _that_
much more. The hard part would be defining those operations, and as
the OP says, it doesn't seem to me like there is an obvious definition
for many of them.

If there's no obvious common definition for what a class is supposed
to do, then there can't really be a standard one...

--
Grant

Re: Standard class for time *period*?

<period-20230328181045@ram.dialup.fu-berlin.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Standard class for time *period*?
Date: 28 Mar 2023 17:12:03 GMT
Organization: Stefan Ram
Lines: 20
Expires: 1 Apr 2024 11:59:58 GMT
Message-ID: <period-20230328181045@ram.dialup.fu-berlin.de>
References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de> <k8drbmFrp9rU2@mid.individual.net> <0354c275-33d2-f3c2-1700-56166ef5153c@tompassin.net> <mailman.2414.1679937935.20444.python-list@python.org> <87y1nhflls.fsf@debian-BULLSEYE-live-builder-AMD64> <bfl52i9t8peoep2mtf5bivis5b2be4aso2@4ax.com> <6423120e.050a0220.5bfa6.d186@mx.google.com> <5a5a2d97-baab-9960-bfda-b352136e4f7c@tompassin.net> <mailman.2430.1680022175.20444.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de RM9tyLsnPdoxzlXLeIEunAhprneJ/LiiMp3nyMuKVKBFKO
X-Copyright: (C) Copyright 2023 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE-1901, en-US, it, fr-FR
 by: Stefan Ram - Tue, 28 Mar 2023 17:12 UTC

Grant Edwards <grant.b.edwards@gmail.com> writes:
>If there's no obvious common definition for what a class is supposed
>to do, then there can't really be a standard one...

The C++ library boost has "boost::locale::date_time_duration".
It has few public methods:

|This class represents a period: a pair of two date_time objects.
|It is generally used as syntactic sugar to calculate
|difference between two dates.

. In Python, the Django scheduler has "periods.py":

|This class represents a period of time. It can return a set
|of occurrences. based on its events, and its time period
|(start and end).

.

Re: Standard class for time *period*?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: PythonList@DancesWithMice.info (dn)
Newsgroups: comp.lang.python
Subject: Re: Standard class for time *period*?
Date: Wed, 29 Mar 2023 07:48:41 +1300
Organization: DWM
Lines: 37
Message-ID: <mailman.2431.1680029939.20444.python-list@python.org>
References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
<k8drbmFrp9rU2@mid.individual.net>
<0354c275-33d2-f3c2-1700-56166ef5153c@tompassin.net>
<mailman.2414.1679937935.20444.python-list@python.org>
<87y1nhflls.fsf@debian-BULLSEYE-live-builder-AMD64>
<bfl52i9t8peoep2mtf5bivis5b2be4aso2@4ax.com>
<87a5zxf2bx.fsf@debian-BULLSEYE-live-builder-AMD64>
<d01b1e2a-04fc-d1ce-96ef-27817ab9f7f7@DancesWithMice.info>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de c9mX03t6z3PrgYtH/jb+OwE+5rcOko9ajHDsFSSodtYg==
Return-Path: <PythonList@DancesWithMice.info>
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=danceswithmice.info header.i=@danceswithmice.info
header.b=hu35OG8j; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.008
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '2022': 0.05; 'class,':
0.05; '=dn': 0.09; 'fails': 0.09; 'from:addr:danceswithmice.info':
0.09; 'from:addr:pythonlist': 0.09; 'obviously': 0.09;
'subject:class': 0.09; '"standard': 0.16; 'attributes': 0.16;
'calculation': 0.16; 'class"': 0.16; 'far,': 0.16; 'involving':
0.16; 'message-id:@DancesWithMice.info': 0.16; 'rationale': 0.16;
'received:51.254': 0.16; 'received:51.254.211': 0.16;
'received:51.254.211.219': 0.16; 'received:cloud': 0.16;
'received:rangi.cloud': 0.16; 'sort,': 0.16; 'problem': 0.16;
'probably': 0.17; 'to:addr:python-list': 0.20; 'i.e.': 0.22;
'idea': 0.24; 'anything': 0.25; 'bit': 0.27; '>>>': 0.28; 'header
:User-Agent:1': 0.30; 'header:Organization:1': 0.31; '(this':
0.32; 'objects': 0.32; 'specified': 0.32; 'weeks,': 0.32;
'received:192.168.1': 0.32; 'but': 0.32; 'subject:for': 0.33;
'there': 0.33; 'able': 0.34; 'header:In-Reply-To:1': 0.34; 'runs':
0.35; 'request': 0.35; 'people': 0.36; 'class': 0.37;
'received:192.168': 0.37; 'could': 0.38; 'two': 0.39; 'single':
0.39; 'list': 0.39; 'use': 0.39; 'difficult': 0.40; 'teams': 0.40;
'both': 0.40; 'team': 0.60; 'duration': 0.64; 'received:51': 0.64;
'order': 0.69; 'season': 0.69; 'above,': 0.70; 'january': 0.71;
'combination': 0.76; 'period': 0.81; 'need.': 0.84; 'points':
0.84; 'identity,': 0.84; 'periods': 0.84; 'surprised': 0.84;
'outline': 0.91
DKIM-Filter: OpenDKIM Filter v2.11.0 vps.rangi.cloud 02A62658C
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=danceswithmice.info;
s=staff; t=1680029463;
bh=KXP0QTjhzBuRfTfvOnXt6YhsQKZVu5qdIVOsl+NHKus=;
h=Date:Subject:To:References:From:In-Reply-To:From;
b=hu35OG8j52QtXVlHXhW7LAWw0X5Qivp6mF2aoqhKMQR+pBjJNuSLKfLOMxaUUKjCx
EUvuWA0EAbH2sJu9LbMYNMJO3dJm3uE4KMabXmW6X8Sb0LMqAMX0oFDLe4uTamz3nh
wsqR8LI6MId1XOeCgRoThnjaOFvSWrcQ+/gHOifnVPlinOlTwkkgrDHvvwI4MV403d
3V+roSJ7jcZjDReBMBtgNdVc/RdHYIQ7bxNQ6yRny/L/4mup6GOzR+yb2YibPjfWTU
oabWZhewrp0p8PtZ4axDJ+aONbjj7C/nBblUa9l2AgIyEBfGd390qVB74C1vGT8DRM
2TrOxba/eV+fw==
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Content-Language: en-GB
In-Reply-To: <87a5zxf2bx.fsf@debian-BULLSEYE-live-builder-AMD64>
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: <d01b1e2a-04fc-d1ce-96ef-27817ab9f7f7@DancesWithMice.info>
X-Mailman-Original-References: <87sfdqjqm3.fsf@hornfels.zedat.fu-berlin.de>
<k8drbmFrp9rU2@mid.individual.net>
<0354c275-33d2-f3c2-1700-56166ef5153c@tompassin.net>
<mailman.2414.1679937935.20444.python-list@python.org>
<87y1nhflls.fsf@debian-BULLSEYE-live-builder-AMD64>
<bfl52i9t8peoep2mtf5bivis5b2be4aso2@4ax.com>
<87a5zxf2bx.fsf@debian-BULLSEYE-live-builder-AMD64>
 by: dn - Tue, 28 Mar 2023 18:48 UTC

>>> 1. Is there a standard class for a 'period', i.e. length of time
>>> specified by a start point and an end point? The start and end
>>> points could obviously be datetimes and the difference a timedelta,
>>> but the period '2022-03-01 00:00 to 2022-03-02 00:00' would be
>>> different to '2023-03-01 00:00 to 2023-03-02 00:00' even if the
>>> *duration* of both periods is the same.
>>>
> But even if I have a single epoch, January 2022 is obviously different
> to January 2023, even thought the duration might be the same. I am just
> surprised that there is no standard Period class, with which I could
> create objects and then be able to sort, check for identity, equality of
> length, amount of overlap, etc. I suppose people just use a
> datetime.datetime pair, as I have been doing so far, and tack on just
> the specific bit of functionality they need.

The request for a "standard class" has probably been answered.

Please give a use-case example to help outline the problem to be solved...

eg if the Apple-picking season starts in January and runs for some
weeks, and the Pear-picking season starts in February (etc), then
calculation will reveal if one team of pickers can do both jobs or if
two teams will be needed. If a list of tasks is to be displayed/printed,
then it would be useful to list both, but in chronological order -
perhaps by start-date.
(this idea of possible application fails to illustrate a rationale for
some of the functionality listed, above, but you get the idea of how to
give us the idea...)

In a custom-class, an __eq__( self, other, ) may be defined to consider
any single or combination of attributes of the two classes. So,
roll-your-own may not be that difficult - although anything involving
time-calculations is wont to open a can-of-worms...

--
Regards,
=dn

Re: Standard class for time *period*?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.neodome.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: cs@cskk.id.au (Cameron Simpson)
Newsgroups: comp.lang.python
Subject: Re: Standard class for time *period*?
Date: Wed, 29 Mar 2023 11:36:38 +1100
Lines: 25
Message-ID: <mailman.2437.1680056946.20444.python-list@python.org>
References: <bfl52i9t8peoep2mtf5bivis5b2be4aso2@4ax.com>
<ZCOIFixK7hIL5URJ@cskk.homeip.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
X-Trace: news.uni-berlin.de jQl3hv9d/jC1YOsH3sesVAAAWP1w+2rds2N6HnQTvTug==
Return-Path: <cameron@cskk.id.au>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.022
X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'effectively': 0.09;
'represents': 0.09; 'subject:class': 0.09; 'though.': 0.09;
'cheers,': 0.11; 'cameron': 0.16; 'duration.': 0.16; 'far,': 0.16;
'from:addr:cs': 0.16; 'from:addr:cskk.id.au': 0.16;
'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net':
0.16; 'received:10.10': 0.16; 'simpson': 0.16; 'skip:> 20': 0.16;
'useful.': 0.16; 'wrote:': 0.16; 'to:addr:python-list': 0.20;
"i've": 0.22; 'code': 0.23; 'asked': 0.29; 'header:User-Agent:1':
0.30; 'seem': 0.31; '(this': 0.32; 'passes': 0.32; 'but': 0.32;
"i'm": 0.33; 'subject:for': 0.33; 'header:In-Reply-To:1': 0.34;
'one.': 0.35; 'files': 0.36; 'using': 0.37; 'hard': 0.37; 'file':
0.38; 'single': 0.39; 'still': 0.40; 'happen': 0.40; 'seconds':
0.40; 'want': 0.40; 'format': 0.62; 'point.': 0.62; 'ever': 0.63;
'duration': 0.64; 'received:userid': 0.66; 'header:Received:6':
0.67; 'slots': 0.69; 'plus': 0.73; 'received:172.16': 0.76;
'represented': 0.84; 'implied': 0.93
X-RG-Spam: Unknown
X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedvhedrvdehhedgfeejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuuffpveftpgfvgffnuffvtfetpdfqfgfvnecuuegrihhlohhuthemucegtddtnecunecujfgurhepfffhvffukfggtggujggffhesthdtredttdervdenucfhrhhomhepvegrmhgvrhhonhcuufhimhhpshhonhcuoegtshestghskhhkrdhiugdrrghuqeenucggtffrrghtthgvrhhnpeelveefgefhgefgheduvdfghefhffejgedvueeihfegleegkeefffeigfdutdevheenucfkphepuddrudeghedrudeirdegtdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhephhgvlhhopegsohhrghdrtghskhhkrdhhohhmvghiphdrnhgvthdpihhnvghtpedurddugeehrdduiedrgedtpdhmrghilhhfrhhomheptggrmhgvrhhonhestghskhhkrdhiugdrrghupdhnsggprhgtphhtthhopedvpdhrtghpthhtoheptghssegtshhkkhdrihgurdgruhdprhgtphhtthhopehphihthhhonhdqlhhishhtsehphihthhhonhdrohhrghdprghuthhhpghushgvrheptghskhhksegsihhgphhonhgurdgtohhmpdhgvghokffrpeetfgdpoffvtefjohhsthepnhhsshhtlhhrghduvdhpqdhsvhgt
X-RazorGate-Vade-Verdict: clean 0
X-RazorGate-Vade-Classification: clean
X-RG-VS-CLASS: clean
X-Authentication-Info: Submitted using ID cskk@bigpond.com
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <bfl52i9t8peoep2mtf5bivis5b2be4aso2@4ax.com>
User-Agent: Mutt/2.2.7 (2022-08-07)
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: <ZCOIFixK7hIL5URJ@cskk.homeip.net>
X-Mailman-Original-References: <bfl52i9t8peoep2mtf5bivis5b2be4aso2@4ax.com>
 by: Cameron Simpson - Wed, 29 Mar 2023 00:36 UTC

On 28Mar2023 08:05, Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote:
> So far, you seem to be the only person who has ever asked for a
> single
>entity incorporating an EPOCH (datetime.datetime) + a DURATION
>(datetime.timedelta).

But not the only person to want one. I've got a timeseries data format
where (within a file) time slots are represented as a seconds offset,
and the file has an associated epoch starting point. Dual to that is
that a timeslot has an offset from the file start, and that is
effectively a (file-epoch, duration) notion.

I've got plenty of code using that which passes around UNIX timestamp
start/stop pairs. Various conversions happen to select the appropriate
file (this keeps the files of bounded size while supporting an unbounded
time range).

Even a UNIX timestamp has an implied epoch, and therefore kind of
represents that epoch plus the timestamp as a duration.

I'm not sure I understand Loris' other requirements though. It might be
hard to write a general thing which was also still useful.

Cheers,
Cameron Simpson <cs@cskk.id.au>

Re: Standard class for time *period*?

<87edp8krn8.fsf@debian-BULLSEYE-live-builder-AMD64>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: loris.bennett@fu-berlin.de (Loris Bennett)
Newsgroups: comp.lang.python
Subject: Re: Standard class for time *period*?
Date: Wed, 29 Mar 2023 08:17:47 +0200
Organization: ZEDAT, Freie Universität Berlin
Lines: 38
Message-ID: <87edp8krn8.fsf@debian-BULLSEYE-live-builder-AMD64>
References: <bfl52i9t8peoep2mtf5bivis5b2be4aso2@4ax.com>
<ZCOIFixK7hIL5URJ@cskk.homeip.net>
<mailman.2437.1680056946.20444.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: news.uni-berlin.de AwcQ85pEeu1CeniaVE5Owgs+AZ9NyFQ3tNBbR8Zl1KHsjH
Cancel-Lock: sha1:TOJxdvDy+KbjHQJ7DM/NfUns1V8=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
 by: Loris Bennett - Wed, 29 Mar 2023 06:17 UTC

Cameron Simpson <cs@cskk.id.au> writes:

> On 28Mar2023 08:05, Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote:
>> So far, you seem to be the only person who has ever asked for
>> a single
>>entity incorporating an EPOCH (datetime.datetime) + a DURATION
>>(datetime.timedelta).
>
> But not the only person to want one. I've got a timeseries data format
> where (within a file) time slots are represented as a seconds offset,
> and the file has an associated epoch starting point. Dual to that is
> that a timeslot has an offset from the file start, and that is
> effectively a (file-epoch, duration) notion.
>
> I've got plenty of code using that which passes around UNIX timestamp
> start/stop pairs. Various conversions happen to select the appropriate
> file (this keeps the files of bounded size while supporting an
> unbounded time range).
>
> Even a UNIX timestamp has an implied epoch, and therefore kind of
> represents that epoch plus the timestamp as a duration.
>
> I'm not sure I understand Loris' other requirements though. It might
> be hard to write a general thing which was also still useful.

I am glad to hear that I am not alone :-) However, my use-case is fairly
trivial, indeed less complicated than yours. So, in truth I don't
really need a Period class. I just thought it might be a sufficiently
generic itch that someone else with a more complicated use-case could
have already scratched. After all, that the datetime classes exist,
even though I only use a tiny part of the total functionality.

Cheers,

Loris

--
This signature is currently under constuction.

Re: Standard class for time *period*?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!hirsch.in-berlin.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: list1@tompassin.net (Thomas Passin)
Newsgroups: comp.lang.python
Subject: Re: Standard class for time *period*?
Date: Wed, 29 Mar 2023 12:48:33 -0400
Lines: 26
Message-ID: <mailman.2441.1680108526.20444.python-list@python.org>
References: <bfl52i9t8peoep2mtf5bivis5b2be4aso2@4ax.com>
<ZCOIFixK7hIL5URJ@cskk.homeip.net>
<mailman.2437.1680056946.20444.python-list@python.org>
<87edp8krn8.fsf@debian-BULLSEYE-live-builder-AMD64>
<9634ab73-3b32-7461-2057-22fe65ca4759@tompassin.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de W+iodkVCLMexI2Pyd2eZwgtBpUxCKfuehntvBBl7GNNQ==
Return-Path: <list1@tompassin.net>
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=tompassin.net header.i=@tompassin.net header.b=P4q3j07I;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'url-ip:140.82/16': 0.03;
'fairly': 0.05; 'library.': 0.05; 'class.': 0.07; ':-)': 0.09;
'datetime': 0.09; 'mechanism': 0.09; 'received:23.83.212': 0.09;
'received:elm.relay.mailchannels.net': 0.09; 'subject:class':
0.09; 'cheers,': 0.11; 'url:github': 0.14; 'url-ip:140/8': 0.15;
'bennett': 0.16; 'indeed': 0.16; 'inspired': 0.16; 'ported': 0.16;
'python3': 0.16; 'received:10.0.0': 0.16; 'received:64.90': 0.16;
'received:64.90.62': 0.16; 'received:64.90.62.162': 0.16;
'received:dreamhost.com': 0.16; 'wrote:': 0.16; 'to:addr:python-
list': 0.20; 'all,': 0.20; 'maybe': 0.22; 'classes': 0.26; 'else':
0.27; 'it,': 0.29; 'header:User-Agent:1': 0.30; 'am,': 0.31;
'module': 0.31; 'received:10.0': 0.32;
'received:mailchannels.net': 0.32;
'received:relay.mailchannels.net': 0.32; 'but': 0.32;
'subject:for': 0.33; 'there': 0.33; 'someone': 0.34; 'header:In-
Reply-To:1': 0.34; 'url:edu': 0.36; 'really': 0.37; 'class': 0.37;
'though': 0.37; 'could': 0.38; 'use': 0.39; 'hear': 0.64; 'less':
0.65; 'worked': 0.67; 'header:Received:6': 0.67; 'received:64':
0.67; 'period': 0.81; 'william': 0.81; 'sufficiently': 0.84;
'tiny': 0.84; 'truth': 0.86; 'glad': 0.86; 'yours.': 0.91
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1680108514; a=rsa-sha256;
cv=none;
b=NWakjtCsmS2Qit7eLBcxqyGKe55ozgJJmVV1Z42Pw26oqEtiEYPdKLg4/VE/q0gF1UkHm5
TkipjQD4DrA4q0NKMekiXJBrDcZaBuR51aCv+uWVSZKOX9mZfbN2lpTq/TRwMifTAbcGOv
G6mPulBi0Uv8TZ9KJvf6qWb5+GORQClvFg1wmGW26IQxnpttlOfbGztJTBvVw/CudkRZhC
s/rj7B5WLDAIn9eFt+UsJNLfxSGg0ioICEIHUcCr4OxBvZZ6q3zzv1kv8sIv6sDG2Ns8sO
OdbKDIzVxj+sqDElf7fl2Jdal0PSWSl7+jfwP71HNIQqvnfvlkqu6wkdWT6low==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
d=mailchannels.net; s=arc-2022; t=1680108514;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding:
in-reply-to:in-reply-to:references:references:dkim-signature;
bh=5Mk2bHFDdFGULOFHSRbdIzIglbR7PLZ+ZygHWDetYMk=;
b=l3vetwtKvzPEQfRiuycPTEPW5lOHm1OVaJUmaeZQa7651hRirAcRn6Pk8e76lwcPEbMe8t
WU4Yj7jxst9TVlwqUOzT7tpCWIsUBv1gweThP1cV5jf0VZ5mdFdsIT4vHB4zCLh9LHNYB0
yuGY2o/yU6ZMo/DkwF1k4HPmnFkFbP6GCdnFtL9fMF5k+rfXqLYx0x8sJM3EQvQCxExJ+b
/1DUPJRlTWUKm8m6EKhFTRB5ei7SSeFg2QcYBgSggTbn31I//6bGk03IPXyKcALMeu2Mb4
QroGKrbyAAWUKY6jFvG125t51u2znqxm9OGkzPSoLkRuIpOaMbJVQWbT8JbMAg==
ARC-Authentication-Results: i=1; rspamd-f7c6fbdc6-57bnb;
auth=pass smtp.auth=dreamhost smtp.mailfrom=list1@tompassin.net
X-Sender-Id: dreamhost|x-authsender|tpassin@tompassin.net
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|tpassin@tompassin.net
X-MailChannels-Auth-Id: dreamhost
X-Blushing-Vacuous: 6c984002075db4c1_1680108514716_4257034073
X-MC-Loop-Signature: 1680108514716:2807118888
X-MC-Ingress-Time: 1680108514716
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tompassin.net;
s=dreamhost; t=1680108514;
bh=5Mk2bHFDdFGULOFHSRbdIzIglbR7PLZ+ZygHWDetYMk=;
h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding;
b=P4q3j07ItyZck/y1yqcfK7lNDSOV03PVE9IQolsvk6h1jtZ7ks+k644SeHm0qXNjy
nvoK1Q1omS45OXgIe4LJKXTrFIHXQkSg+oACrQUJ/hLjhPzBMHIJRUOoF+fcHeYtKx
+jmsds695xaqWvfZrfoseJRH/pJ1CHxGnHG9wbhCX3vVNhvgDZl34q87cdkN9BLbsL
UTpzydOI9P7NohiGg0KBJ3+6V9YAcO8e00D6yn/foUvtIj+NB/W9KMN6x7t2Dc1rx8
2bcX+cU1lO3j2k62O2h92CuRi4sgZbgai+9k7P5oQTo5gsDu0ZTnlk/VE64ZXL0HQJ
2bDb/CB9HTSKQ==
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Content-Language: en-US
In-Reply-To: <87edp8krn8.fsf@debian-BULLSEYE-live-builder-AMD64>
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: <9634ab73-3b32-7461-2057-22fe65ca4759@tompassin.net>
X-Mailman-Original-References: <bfl52i9t8peoep2mtf5bivis5b2be4aso2@4ax.com>
<ZCOIFixK7hIL5URJ@cskk.homeip.net>
<mailman.2437.1680056946.20444.python-list@python.org>
<87edp8krn8.fsf@debian-BULLSEYE-live-builder-AMD64>
 by: Thomas Passin - Wed, 29 Mar 2023 16:48 UTC

On 3/29/2023 2:17 AM, Loris Bennett wrote:
>
> I am glad to hear that I am not alone :-) However, my use-case is fairly
> trivial, indeed less complicated than yours. So, in truth I don't
> really need a Period class. I just thought it might be a sufficiently
> generic itch that someone else with a more complicated use-case could
> have already scratched. After all, that the datetime classes exist,
> even though I only use a tiny part of the total functionality.
>
> Cheers,
>
> Loris
>

Maybe there is - https://github.com/LinkCareServices/period

"Period is a basic time period checking library.

Period is based on period.py by William S. Annis. (available at
https://www.biostat.wisc.edu/~annis/creations/period.py.html) and ported
to python3 with a few improvements. Period.py was in part inspired by
perl's Time::Period module and the time class mechanism of Cfengine."

I have not worked with it, but it may be worth looking at. I found this
by going to PyPi.org and asking for "period".

Re: Standard class for time *period*?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: cs@cskk.id.au (Cameron Simpson)
Newsgroups: comp.lang.python
Subject: Re: Standard class for time *period*?
Date: Thu, 30 Mar 2023 10:13:42 +1100
Lines: 25
Message-ID: <mailman.2450.1680135893.20444.python-list@python.org>
References: <87edp8krn8.fsf@debian-BULLSEYE-live-builder-AMD64>
<ZCTGJt59ZxAkHLbN@cskk.homeip.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
X-Trace: news.uni-berlin.de yT+pxNxStmSwQk4KJaXHeg7Zgpkgv31mpIJtErKFmwZw==
Return-Path: <cameron@cskk.id.au>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.010
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'url-ip:140.82/16': 0.03;
'fairly': 0.05; 'class.': 0.07; ':-)': 0.09; 'skip:` 10': 0.09;
'subject:class': 0.09; 'cheers,': 0.11; 'url:github': 0.14;
'possible,': 0.15; 'that.': 0.15; 'url-ip:140/8': 0.15; 'bennett':
0.16; 'cameron': 0.16; 'comparing': 0.16; 'from:addr:cs': 0.16;
'from:addr:cskk.id.au': 0.16; 'from:name:cameron simpson': 0.16;
'indeed': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'presently':
0.16; 'received:10.10': 0.16; 'simpson': 0.16; 'wrote:': 0.16;
'to:addr:python-list': 0.20; 'anything': 0.25; 'else': 0.27;
'etc': 0.28; 'fact': 0.28; 'it,': 0.29; 'header:User-Agent:1':
0.30; 'whole': 0.30; 'module': 0.31; "doesn't": 0.32; 'but': 0.32;
"i'm": 0.33; 'subject:for': 0.33; 'someone': 0.34; 'header:In-
Reply-To:1': 0.34; 'really': 0.37; 'using': 0.37; 'class': 0.37;
'could': 0.38; 'use': 0.39; 'calendar': 0.40; 'try': 0.40; 'stay':
0.61; 'hear': 0.64; 'less': 0.65; 'received:userid': 0.66;
'header:Received:6': 0.67; 'url:css': 0.69; 'easy': 0.74;
'received:172.16': 0.76; 'period': 0.81; 'url:lib': 0.81; 'spans':
0.84; 'sufficiently': 0.84; 'whole.': 0.84; 'truth': 0.86; 'glad':
0.86; 'yours.': 0.91
X-RG-Spam: Unknown
X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedvhedrvdehjedgudekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuuffpveftpgfvgffnuffvtfetpdfqfgfvnecuuegrihhlohhuthemucegtddtnecunecujfgurhepfffhvffukfggtggujggffhesthdtredttdervdenucfhrhhomhepvegrmhgvrhhonhcuufhimhhpshhonhcuoegtshestghskhhkrdhiugdrrghuqeenucggtffrrghtthgvrhhnpeeuudehteeuvdefffdtleffledvueefudekheehhfehvefflefhvdfhveejgfejveenucffohhmrghinhepghhithhhuhgsrdgtohhmpdhtihhmvghsvghrihgvshdrphihnecukfhppedurddugeehrdduiedrgedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehhvghlohepsghorhhgrdgtshhkkhdrhhhomhgvihhprdhnvghtpdhinhgvthepuddrudeghedrudeirdegtddpmhgrihhlfhhrohhmpegtrghmvghrohhnsegtshhkkhdrihgurdgruhdpnhgspghrtghpthhtohepvddprhgtphhtthhopegtshestghskhhkrdhiugdrrghupdhrtghpthhtohepphihthhhohhnqdhlihhsthesphihthhhohhnrdhorhhgpdgruhhthhgpuhhsvghrpegtshhkkhessghighhpohhnugdrtghomhdpghgvohfkrfeptegfpdfovfetjfhoshhtpehnshhsthhlrhhgudduphdqshhvtg
X-RazorGate-Vade-Verdict: clean 0
X-RazorGate-Vade-Classification: clean
X-RG-VS-CLASS: clean
X-Authentication-Info: Submitted using ID cskk@bigpond.com
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <87edp8krn8.fsf@debian-BULLSEYE-live-builder-AMD64>
User-Agent: Mutt/2.2.7 (2022-08-07)
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: <ZCTGJt59ZxAkHLbN@cskk.homeip.net>
X-Mailman-Original-References: <87edp8krn8.fsf@debian-BULLSEYE-live-builder-AMD64>
 by: Cameron Simpson - Wed, 29 Mar 2023 23:13 UTC

On 29Mar2023 08:17, Loris Bennett <loris.bennett@fu-berlin.de> wrote:
>I am glad to hear that I am not alone :-) However, my use-case is fairly
>trivial, indeed less complicated than yours. So, in truth I don't
>really need a Period class. I just thought it might be a sufficiently
>generic itch that someone else with a more complicated use-case could
>have already scratched.

Well, my attitude to time spans is to get the start and end (or start
and length, but I prefer the former) as UNIX timestamps and work from
that. I try to stay as far from datetimes as possible, because of their
foibles (particularly timezones, but really the whole calendar
decomposition etc) and use them only for presentation.

I do in fact have a `TimePartition` in my timeseries module; it
presently doesn't do comparisons because I'm not comparing them - I'm
just using them as slices into the timeseries data on the whole.

https://github.com/cameron-simpson/css/blob/0ade6d191833b87cab8826d7ecaee4d114992c45/lib/python/cs/timeseries.py#L2163

But it would be easy to give that class `__lt__` etc methods.

You're welcome to use it, or anything from the module (it's on PyPI).

Cheers,
Cameron Simpson <cs@cskk.id.au>


devel / comp.lang.python / Standard class for time *period*?

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor