>>> def round_time(x):
... hour_in_seconds = 60 * 60
... half_hour_in_seconds = 60 * 30
... if x % hour_in_seconds > half_hour_in_seconds:
... return ((x // hour_in_seconds) + 1) * hour_in_seconds
... else:
... return (x // hour_in_seconds) * hour_in_seconds
...
>>>
>>> str(datetime.timedelta(seconds=3590))
'0:59:50'
>>> str(datetime.timedelta(seconds=round_time(3590)))
'1:00:00'
>>> str(datetime.timedelta(seconds=390))
'0:06:30'
>>> str(datetime.timedelta(seconds=round_time(390)))
'0:00:00'
>>> str(datetime.timedelta(seconds=5390))
'1:29:50'
>>> str(datetime.timedelta(seconds=round_time(5390)))
'1:00:00'
>>> str(datetime.timedelta(seconds=7390))
'2:03:10'
>>> str(datetime.timedelta(seconds=round_time(7390)))
'2:00:00'