Standard class for time *period*?
Loris Bennett
loris.bennett at fu-berlin.de
Tue Mar 28 09:11:14 EDT 2023
Dennis Lee Bieber <wlfraed at ix.netcom.com> writes:
> On Tue, 28 Mar 2023 08:14:55 +0200, "Loris Bennett"
> <loris.bennett at 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.
More information about the Python-list
mailing list