Skip to content

Instantly share code, notes, and snippets.

@maxehmookau
Created April 5, 2013 20:30
Show Gist options
  • Save maxehmookau/5322387 to your computer and use it in GitHub Desktop.
Save maxehmookau/5322387 to your computer and use it in GitHub Desktop.
This sucks, but there must be a better way to do it.
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