You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

duration.py 519 B

123456789101112131415161718192021
  1. """Version of str(timedelta) which is not English specific."""
  2. def duration_string(duration):
  3. days = duration.days
  4. seconds = duration.seconds
  5. microseconds = duration.microseconds
  6. minutes = seconds // 60
  7. seconds = seconds % 60
  8. hours = minutes // 60
  9. minutes = minutes % 60
  10. string = '{:02d}:{:02d}:{:02d}'.format(hours, minutes, seconds)
  11. if days:
  12. string = '{} '.format(days) + string
  13. if microseconds:
  14. string += '.{:06d}'.format(microseconds)
  15. return string