Thomas Passin <li...@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. -- https://mail.python.org/mailman/listinfo/python-list