Add waiting for next period

This commit is contained in:
Tobias Reisinger 2024-04-26 00:00:42 +02:00
parent 6f2deb38e1
commit 0b0350da0e
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
5 changed files with 105 additions and 37 deletions
emgauwa-lib/src/db

View file

@ -198,4 +198,12 @@ impl DbSchedule {
pub fn is_on(&self, now: &NaiveTime) -> bool {
self.periods.0.iter().any(|period| period.is_on(now))
}
pub fn get_next_time(&self, now: &NaiveTime) -> Option<NaiveTime> {
self.periods
.0
.iter()
.filter_map(|period| period.get_next_time(now))
.min()
}
}