Skip to content
Myr

chore: Change to use `jiff::Zoned`

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Supports when the duration contains calendar units.

authored by Shun Sakai · committed by Shun Sakai · parent c670a0b · Browse files · 1 file+6 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−4 removed

  • other:+6 added−4 removed

1 file+6 added−4 removed

modified:src/filter/time.rs+6 added-4 removed
1use chrono::{DateTime, Local, NaiveDate, NaiveDateTime};2use jiff::Span;2use jiff::{Span, Zoned};34use std::time::{Duration, SystemTime};4use std::time::SystemTime;56/// Filter based on time ranges.7#[derive(Debug, PartialEq, Eq)]8pub enum TimeFilter {
3 unmodified lines
1213impl TimeFilter {14 fn from_str(ref_time: &SystemTime, s: &str) -> Option<SystemTime> {15 s.parse::<Span>()16 .and_then(Duration::try_from)17 .map(|duration| *ref_time - duration)16 .and_then(|duration| {17 Zoned::try_from(*ref_time).and_then(|zoned| zoned.checked_sub(duration))18 })19 .map(SystemTime::from)20 .ok()21 .or_else(|| {22 DateTime::parse_from_rfc3339(s)23 .map(|dt| dt.into())
145 unmodified lines