feat: add reservation booking
Some checks failed
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/clippy Pipeline failed
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
Jef Roosens 2023-05-17 10:52:33 +02:00
parent fe171fdc8e
commit 83ff00d582
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
4 changed files with 169 additions and 72 deletions

View file

@ -73,4 +73,13 @@ impl Resource {
.filter(|(hour, _)| hour.state == 1)
.collect()
}
/// Returns whether a slot with the given state and time bounds is present in the list of
/// hours.
pub fn has_slot(&self, start_time: NaiveTime, end_time: NaiveTime, state: u32) -> bool {
self.condensed_hours()
.into_iter()
.filter(|(block, _)| block.state == state)
.any(|(block, duration)| start_time >= block.hour && end_time <= block.hour + duration)
}
}