Skip to content

Instantly share code, notes, and snippets.

@scottjg
Created May 6, 2014 19:31
Show Gist options
  • Save scottjg/2c7b1ef6e5eb1d223548 to your computer and use it in GitHub Desktop.
Save scottjg/2c7b1ef6e5eb1d223548 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'date'
prev_dt = nil
prev_line = nil
$stdin.each_line do |line|
time_str = line[1..25]
dt = DateTime.parse(time_str) rescue next
if prev_dt != nil
#p '---'
#p prev_dt
#p dt
#p line
secs = ((dt - prev_dt) * 24 * 60 * 60).to_i
if (secs > 0)
puts "(#{secs.to_s.rjust(10, '0')}s) #{line}"
end
end
prev_dt = dt
prev_line = line
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment