Add is_on functions

This commit is contained in:
Tobias Reisinger 2024-04-24 03:03:21 +02:00
parent 6414083af0
commit 0460e838bc
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
4 changed files with 32 additions and 2 deletions
emgauwa-lib/src/db

View file

@ -1,6 +1,7 @@
use std::borrow::Borrow;
use std::ops::DerefMut;
use chrono::NaiveTime;
use serde_derive::{Deserialize, Serialize};
use sqlx::pool::PoolConnection;
use sqlx::Sqlite;
@ -193,4 +194,8 @@ impl DbSchedule {
}
Ok(())
}
pub fn is_on(&self, now: &NaiveTime) -> bool {
self.periods.0.iter().any(|period| period.is_on(now))
}
}