Created
September 8, 2011 03:46
-
-
Save nhocki/1202554 to your computer and use it in GitHub Desktop.
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
# No es un poco más rápido sin el Date object? | |
# Crear un objeto cada vez es un poco feo. | |
# Sobre todo cuando es una función que se llama como 3mil veces | |
# Además, new Date(milisecs) es una mierda. | |
toHumanTime: -> | |
# date = new Date(@milliSeconds) | |
hours = Math.floor(@milliSeconds / (1000 * 60 * 60)) % 24 | |
mins = Math.floor(@milliSeconds / (1000 * 60)) % 60 # date.getMinutes() | |
secs = Math.floor(@milliSeconds / (1000)) % 60 # date.getSeconds() | |
hours = "0" + hours if hours < 10 | |
mins = "0" + mins if mins < 10 | |
secs = "0" + secs if secs < 10 | |
if hours < 1 | |
"#{mins}:#{secs}" | |
else | |
"#{hours}:#{mins}:#{secs}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah! Found it! http://jsperf.com/