Created
October 23, 2014 15:36
-
-
Save karthikbgl/33ed3afd98e842b9c4d1 to your computer and use it in GitHub Desktop.
Time elapsed in seconds
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 secondsToStr(t): | |
''' | |
This snippet converts the time elapsed in | |
seconds to HH:MM:SS.mmm | |
Example: | |
>>> secondsToStr(123456) | |
'34:17:36.000' | |
''' | |
return "%d:%02d:%02d.%03d" % \ | |
reduce(lambda x, y: divmod(x[0], y) + x[1:], | |
[(t*1000,), 1000, 60, 60]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment