fork download
  1. $VERBOSE = true
  2.  
  3. now = Time.local 2012, 1, 1, 0, 0, 30, 3 * 1000
  4. want = (now - (60 * 15))..now
  5. time_in_logs = %r!^(?<mon>\d{2})/
  6. (?<day>\d{2})/
  7. (?<year>\d{4})\
  8. (?<hour>\d{2}):
  9. (?<min>\d{2}):
  10. (?<sec>\d{2}):
  11. (?<millisec>\d{1,3})!x
  12.  
  13. STDIN.grep time_in_logs do |log|
  14. if want.cover? Time.local($~[:year], $~[:mon], $~[:day], $~[:hour],
  15. $~[:min], $~[:sec], $~[:millisec].to_i * 1000)
  16. puts log
  17. end
  18. end
Success #stdin #stdout 0s 4760KB
stdin
12/31/2011 22:00:00:000 way before
12/31/2011 23:45:30:2 way before
12/31/2011 23:45:30:10 just inside
01/01/2012 00:00:20:000 Some Data just before now
01/01/2012 00:00:40:000 Some Data just after now
01/01/2012 01:00:20:000 An hour later
stdout
12/31/2011 23:45:30:10 just inside
01/01/2012 00:00:20:000 Some Data just before now