Working with time values greater than 24 hours
python, time
Solution
As I understand, you want a sum of all times and not difference. So you can convert your time to timedelta and then sum it:
>>> from datetime import timedelta
# get hours, minutes and seconds
>>> tm1 = [map(int, x.split(':')) for x in times]
# convert to timedelta
>>> tm2 = [timedelta(hours=x[0], minutes=x[1], seconds=x[2]) for x in tm1]
# sum
>>> print sum(tm2, timedelta())
1 day, 0:58:35
Problem
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 ```