Skip to content

Instantly share code, notes, and snippets.

View kangasbros's full-sized avatar

Jeremias Kangas kangasbros

  • Helsinki
View GitHub Profile
View python timedelta_to_tuple
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))