feat: add reservation booking
This commit is contained in:
parent
fe171fdc8e
commit
83ff00d582
4 changed files with 169 additions and 72 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue