Fix out-of-range move commands

This commit is contained in:
Joscha 2021-12-12 19:09:38 +00:00
parent 240becd28d
commit 6f1a533b95
4 changed files with 39 additions and 3 deletions

View file

@ -28,6 +28,22 @@ impl DateRange {
Self::new(self.from, until)
}
pub fn containing(&self, date: NaiveDate) -> Self {
if date < self.from {
Self {
from: date,
until: self.until,
}
} else if self.until < date {
Self {
from: self.from,
until: date,
}
} else {
*self
}
}
pub fn contains(&self, date: NaiveDate) -> bool {
self.from <= date && date <= self.until
}