Standard class for time *period*?

Gary Herron gherron at digipen.edu
Mon Mar 27 12:43:02 EDT 2023


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 at 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
>


More information about the Python-list mailing list