Skip to content

Instantly share code, notes, and snippets.

View ranzes's full-sized avatar

Ranzes Tamar ranzes

  • Ranaworks
  • Brazil
View GitHub Profile
@ikedumancas
ikedumancas / utils.py
Created June 10, 2018 07:44
Python: Convert timedelta to HHMMSS string
def format_timedelta_to_HHMMSS(td):
td_in_seconds = td.total_seconds()
hours, remainder = divmod(td_in_seconds, 3600)
minutes, seconds = divmod(remainder, 60)
hours = int(hours)
minutes = int(minutes)
seconds = int(seconds)
if minutes < 10:
minutes = "0{}".format(minutes)
if seconds < 10: