Collect relevant entries based on different modes

This commit is contained in:
Joscha 2021-12-04 18:44:56 +01:00
parent b8aeb79323
commit f42027e378
3 changed files with 122 additions and 11 deletions

View file

@ -1,4 +1,4 @@
use std::fmt;
use std::{cmp, fmt};
use chrono::NaiveDate;
@ -372,6 +372,29 @@ impl DoneDate {
DoneDate::DateToDateWithTime { root, .. } => *root,
}
}
pub fn other(&self) -> Option<NaiveDate> {
match self {
DoneDate::Date { .. } => None,
DoneDate::DateWithTime { .. } => None,
DoneDate::DateToDate { other, .. } => Some(*other),
DoneDate::DateToDateWithTime { other, .. } => Some(*other),
}
}
pub fn first(&self) -> NaiveDate {
match self.other() {
None => self.root(),
Some(other) => cmp::min(self.root(), other),
}
}
pub fn last(&self) -> NaiveDate {
match self.other() {
None => self.root(),
Some(other) => cmp::max(self.root(), other),
}
}
}
#[derive(Debug)]