Skip to content

Instantly share code, notes, and snippets.

@judofyr
Created September 26, 2009 19:29
Show Gist options
  • Save judofyr/194383 to your computer and use it in GitHub Desktop.
Save judofyr/194383 to your computer and use it in GitHub Desktop.
require 'time'
require 'optparse'
%w[operation time].
inject(OptionParser.new){|o,i|
o.on("-"+c=i[0,1],"--#{i} X"){|v|eval("$#{c}=v")}
o}.parse!;$t,$o=$t.tr(',','.').to_f,$o=='sub'?:-:
:+;puts File.read(ARGV[0]).gsub(/^(.*) --> (.*)$/){
[$1,$2].map{|x|(t=Time.parse(x.strip).send($o,$t)).
strftime("%H:%M:%S,#{t.usec}00")[0,12]}*' --> '}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment