Created
April 24, 2015 20:52
-
-
Save mirekfranc/25ef855ea0494d0993f7 to your computer and use it in GitHub Desktop.
HH:MM:SS time formatting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def time_format (seconds): | |
m, s = divmod (seconds, 60) | |
h, m = divmod (m, 60) | |
if h: | |
return "{0:2}:{1:02}:{2:02}".format (h, m, s) | |
elif m: | |
return "{0:5}:{1:02}".format (m, s) | |
else: | |
return "{0:8}".format (s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment