Skip to content

Instantly share code, notes, and snippets.

@kangasbros
Created December 8, 2014 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kangasbros/8b37f7ba4e0de623b691 to your computer and use it in GitHub Desktop.
Save kangasbros/8b37f7ba4e0de623b691 to your computer and use it in GitHub Desktop.
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