Skip to content

Instantly share code, notes, and snippets.

@zeroeth
Created March 8, 2013 22:22
Show Gist options
  • Select an option

  • Save zeroeth/5120395 to your computer and use it in GitHub Desktop.

Select an option

Save zeroeth/5120395 to your computer and use it in GitHub Desktop.
timestamp to seconds
def duration_to_seconds(duration)
numbers = duration.split(":").map(&:to_i)
(numbers[0]*60) + numbers[1]
end
total_seconds = duration_to_seconds("12:05")
puts "#{total_seconds} should_equal 725"
@zeroeth

zeroeth commented Mar 8, 2013

Copy link
Copy Markdown
Author

map{|x| x.to_i} == map(&:to_i)

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