use chrono::NaiveDate; use super::primitives::{Span, Spanned, Time, Weekday}; #[derive(Debug, Clone, Copy)] pub enum DeltaStep { /// `y`, move by a year, keeping the same month and day Year(i32), /// `m`, move by a month, keeping the same day `d` Month(i32), /// `M`, move by a month, keeping the same day `D` MonthReverse(i32), /// `d` Day(i32), /// `w`, move by 7 days Week(i32), /// `h` Hour(i32), /// `m` Minute(i32), /// `mon`, `tue`, `wed`, `thu`, `fri`, `sat`, `sun` /// /// Move to the next occurrence of the specified weekday Weekday(i32, Weekday), } impl DeltaStep { pub fn amount(&self) -> i32 { match self { DeltaStep::Year(i) => *i, DeltaStep::Month(i) => *i, DeltaStep::MonthReverse(i) => *i, DeltaStep::Day(i) => *i, DeltaStep::Week(i) => *i, DeltaStep::Hour(i) => *i, DeltaStep::Minute(i) => *i, DeltaStep::Weekday(i, _) => *i, } } pub fn name(&self) -> &'static str { match self { DeltaStep::Year(_) => "y", DeltaStep::Month(_) => "m", DeltaStep::MonthReverse(_) => "M", DeltaStep::Day(_) => "d", DeltaStep::Week(_) => "w", DeltaStep::Hour(_) => "h", DeltaStep::Minute(_) => "min", DeltaStep::Weekday(_, wd) => wd.name(), } } } #[derive(Debug, Default)] pub struct Delta(pub Vec>); #[derive(Debug)] pub struct Repeat { /// Start at the date when the latest `DONE` was created instead of the /// task's previous occurrence. pub start_at_done: bool, pub delta: Spanned, } #[derive(Debug)] pub struct DateSpec { pub start: NaiveDate, pub start_delta: Option, pub start_time: Option