Created
January 3, 2017 01:12
-
-
Save petertseng/3b8bca39496cd931dd24e07be9a14526 to your computer and use it in GitHub Desktop.
VTT offset
This file contains hidden or 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
| if ARGV.empty? | |
| puts "usage: #{$PROGRAM_NAME} offset [file] (or stdin)" | |
| exit 1 | |
| end | |
| offset = ARGV.shift.to_i | |
| ARGF.each_line { |l| | |
| unless l.include?('-->') | |
| puts l | |
| next | |
| end | |
| l.scan(/(\d\d):(\d\d):(\d\d)/).each { |h, m, s| | |
| t = h.to_i * 3600 + m.to_i * 60 + s.to_i - offset | |
| l["#{h}:#{m}:#{s}"] = Time.at(t).utc.strftime('%H:%M:%S') | |
| } | |
| puts l | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment