Skip to content

Instantly share code, notes, and snippets.

@petertseng
Created January 3, 2017 01:12
Show Gist options
  • Select an option

  • Save petertseng/3b8bca39496cd931dd24e07be9a14526 to your computer and use it in GitHub Desktop.

Select an option

Save petertseng/3b8bca39496cd931dd24e07be9a14526 to your computer and use it in GitHub Desktop.
VTT offset
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