Re: Standard class for time *period*?

2023-03-29 Thread Cameron Simpson
On 29Mar2023 08:17, 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

Re: Standard class for time *period*?

2023-03-29 Thread Cameron Simpson
On 30Mar2023 10:13, Cameron Simpson wrote: 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.

Re: Standard class for time *period*?

2023-03-29 Thread Thomas Passin
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

Re: Standard class for time *period*?

2023-03-29 Thread Loris Bennett
Cameron Simpson writes: > On 28Mar2023 08:05, Dennis Lee Bieber wrote: >> So far, you seem to be the only person who has ever asked for >> asingle >>entity incorporating an EPOCH (datetime.datetime) + a DURATION >>(datetime.timedelta). > > But not the only person to want one. I've got

Re: Standard class for time *period*?

2023-03-28 Thread Cameron Simpson
On 28Mar2023 08:05, Dennis Lee Bieber 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

Re: Standard class for time *period*?

2023-03-28 Thread dn via Python-list
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

Re: Standard class for time *period*?

2023-03-28 Thread Grant Edwards
On 2023-03-28, Thomas Passin wrote: > On 3/28/2023 12:13 PM, Grant Edwards wrote: >> On 2023-03-28, Dennis Lee Bieber 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).

Re: Standard class for time *period*?

2023-03-28 Thread Thomas Passin
On 3/28/2023 12:13 PM, Grant Edwards wrote: On 2023-03-28, Dennis Lee Bieber 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

Re: Standard class for time *period*?

2023-03-28 Thread Grant Edwards
On 2023-03-28, Dennis Lee Bieber 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

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

2023-03-28 Thread Karsten Hilbert
> 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

Re: Standard class for time *period*?

2023-03-28 Thread rbowman
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

Re: Standard class for time *period*?

2023-03-28 Thread Dennis Lee Bieber
On Tue, 28 Mar 2023 08:14:55 +0200, "Loris Bennett" 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

Re: Standard class for time *period*?

2023-03-28 Thread Loris Bennett
Thomas Passin 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

Re: Standard class for time *period*?

2023-03-28 Thread Loris Bennett
Dennis Lee Bieber writes: > On Tue, 28 Mar 2023 08:14:55 +0200, "Loris Bennett" > 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

Re: Standard class for time *period*?

2023-03-27 Thread Thomas Passin
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

Re: Standard class for time *period*?

2023-03-27 Thread Gary Herron
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,

Re: Standard class for time *period*?

2023-03-27 Thread rbowman
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

Re: Standard class for time *period*?

2023-03-27 Thread Loris Bennett
r...@zedat.fu-berlin.de (Stefan Ram) writes: > r...@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

Standard class for time *period*?

2023-03-27 Thread Loris Bennett
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