Skip to content
Create a gist now

Instantly share code, notes, and snippets.

@slhck /time-diff.rb
Last active

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.parse(time2_str) - Time.parse(time1_str) )
(t - t.gmt_offset).strftime("%H:%M:%S.%L")
ins ="ins.txt")
outs ="outs.txt")
diffs ="diffs.txt", "w")
inlines =
outlines =
ins.each { |l| inlines << l }
outs.each { |l| outlines << l } { |ins, outs| diffs.puts time_diff(ins, outs) }
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.