Standard class for time *period*?

Loris Bennett loris.bennett at fu-berlin.de
Wed Mar 29 02:17:47 EDT 2023


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

> On 28Mar2023 08:05, Dennis Lee Bieber <wlfraed at 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.


More information about the Python-list mailing list