Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def timedelta_to_tuple(td):
"""Return an (hours, minutes) tuple
"""
tot_secs = abs(td.total_seconds())
remaining_secs = tot_secs % 3600
hours = (tot_secs - remaining_secs) / 3600
return int(hours), int(round(remaining_secs/60))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment