From d50fdaa06f3509696d04cdd564ebb9b6265c46c4 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 15 Oct 2018 17:32:22 +0200 Subject: add time based filtering This accepts timestamps in the following formats: * Human-readable, like "15d", taken relative to the current time. * rfc3339-like "2018-03-14 13:13:00" More formats might be added in the future. --- src/filters.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/filters.rs') diff --git a/src/filters.rs b/src/filters.rs index 1549c26..c6df6e8 100644 --- a/src/filters.rs +++ b/src/filters.rs @@ -31,3 +31,17 @@ pub fn filter_outcome(result: &LogResult, opt: &Opt) -> bool { _ => false, } } + +/// Do filtering based on encounter time. +pub fn filter_time(result: &LogResult, opt: &Opt) -> bool { + let after_ok = match opt.after { + Some(time) => time <= result.time, + None => true, + }; + let before_ok = match opt.before { + Some(time) => time >= result.time, + None => true, + }; + + after_ok && before_ok +} -- cgit v1.2.3