Created
April 5, 2013 20:30
-
-
Save maxehmookau/5322387 to your computer and use it in GitHub Desktop.
This sucks, but there must be a better way to do it.
This file contains hidden or 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 humanised_time | |
if milliseconds < 60000 | |
"#{ milliseconds / 1000 }sec" | |
elsif milliseconds > 60000 && milliseconds < 3600000 | |
"#{ ((milliseconds / (1000 * 60)) % 60) }m #{ (milliseconds / 1000) % 60 }s" | |
else | |
"#{ ((milliseconds / (1000 * 60 * 60)) % 24) }h #{ ((milliseconds / (1000 * 60)) % 60) }m #{ (milliseconds / 1000) % 60 }s" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment