Sunday, 18 August 2013

Working with time values greater than 24 hours

Working with time values greater than 24 hours

How does one work with time periods greater than 24 hours in python? I
looked at the datetime.time object but this seems to be for handling the
time of a day, not time in general.
datetime.time has the requirement of 0 <= hour < 24 which makes it useless
if you want to record a time of more than 24 hours unless I am missing
something?
Say for example I wanted to calculate the total time worked by someone. I
know the time they've taken to complete tasks individually. What class
should I be using to safely calculate that total time.
My input data would look something like this:
# The times in HH:MM:SS
times = ["16:35:21", "8:23:14"]
total_time = ? # 24:58:35

No comments:

Post a Comment