diff options
author | Daniel <kingdread@gmx.de> | 2018-10-15 17:32:22 +0200 |
---|---|---|
committer | Daniel <kingdread@gmx.de> | 2018-10-15 17:32:22 +0200 |
commit | d50fdaa06f3509696d04cdd564ebb9b6265c46c4 (patch) | |
tree | 5b8678bbc18eeaa2bdfd8cfa96a9bb74147f864a /src/filters.rs | |
parent | 46e99ad65d41a9f03bcefb6bc17b3fa00bca6b79 (diff) | |
download | raidgrep-d50fdaa06f3509696d04cdd564ebb9b6265c46c4.tar.gz raidgrep-d50fdaa06f3509696d04cdd564ebb9b6265c46c4.tar.bz2 raidgrep-d50fdaa06f3509696d04cdd564ebb9b6265c46c4.zip |
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.
Diffstat (limited to 'src/filters.rs')
-rw-r--r-- | src/filters.rs | 14 |
1 files changed, 14 insertions, 0 deletions
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 +} |