Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add methods for getting start and end time in seconds #3

Open
jronallo opened this issue Feb 19, 2013 · 0 comments
Open

add methods for getting start and end time in seconds #3

jronallo opened this issue Feb 19, 2013 · 0 comments

Comments

@jronallo
Copy link
Owner

It would be convenient to have a cue return a timestamp of a start or end time converted into seconds. The methods might be #start_seconds and #end_seconds. Here's a method which converts a WebVTT formatted timestamp into seconds:

def jump_time(timestamp)
  time_parts = timestamp.split(':')
  seconds = time_parts.pop
  minutes = time_parts.pop
  hours   = time_parts.first if !time_parts.blank?
  total_seconds = hours.to_i.hours.seconds
  total_seconds += minutes.to_i.minutes.seconds
  total_seconds += seconds.split('.').first.to_i
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant