I have a timedelta time like this:
datetime.timedelta(0, 175, 941041)
I want to convert this into duration. For example:
1 second
2-59 seconds
1 minute
2minutes-59minutes
1 hour
1 hour 50 minutes
2 hours
1 day 5 hours 45 minutes
How can I do this in Python?
First, I tried to converting timedelta into seconds like this and later convert into duration:
def timedelta_to_seconds(td):
return td.microseconds + (td.seconds + td.days * 86400)
But I get this error while running this function:
AttributeError: 'function' object has no attribute 'microseconds'