Skip to content

@slhck /time-diff.rb
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Calculates calculates the difference between time as HH:MM:SS.msec
#!/usr/bin/env ruby
# calculates the difference between time as
# "HH:MM:SS.msec" and "HH:MM:SS.msec"
# into a file called diffs.txt
require "Time"
def time_diff(time1_str, time2_str)
t = Time.at( Time.parse(time2_str) - Time.parse(time1_str) )
(t - t.gmt_offset).strftime("%H:%M:%S.%L")
end
ins = File.open("ins.txt")
outs = File.open("outs.txt")
diffs = File.new("diffs.txt", "w")
inlines = Array.new
outlines = Array.new
ins.each { |l| inlines << l }
outs.each { |l| outlines << l }
inlines.zip(outlines).each { |ins, outs| diffs.puts time_diff(ins, outs) }
diffs.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.