Created
April 27, 2012 16:58
-
-
Save moresheth/2510803 to your computer and use it in GitHub Desktop.
Convert seconds to extended time
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
# Caveman | |
def seconds_to_extended(seconds) | |
hours = 0 | |
minutes = 0 | |
while seconds >= 3600 | |
hours += 1 | |
seconds -= 3600 | |
end | |
while seconds >= 60 | |
minutes += 1 | |
seconds -= 60 | |
end | |
str = ( hours > 0 ? "#{hours}:#{minutes.to_s.rjust(2,'0')}:" : "#{minutes}:" ) + seconds.to_s.rjust(2,'0') | |
return str | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice, I was surprised I couldn't find this more easily. I'm calling it youtube_time.