Skip to content

Instantly share code, notes, and snippets.

@moresheth
Created April 27, 2012 16:58
Show Gist options
  • Save moresheth/2510803 to your computer and use it in GitHub Desktop.
Save moresheth/2510803 to your computer and use it in GitHub Desktop.
Convert seconds to extended time
# 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
@eliblocks
Copy link

Nice, I was surprised I couldn't find this more easily. I'm calling it youtube_time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment