use std::time::Duration;
use time::{Date, OffsetDateTime, Time};
pub struct SchedulerConfig {
pub interval: Option<Duration>,
pub start_date: Date,
pub start_time: Time,
}
impl SchedulerConfig {
pub fn new() -> Self {
SchedulerConfig {
interval: None,
start_date: OffsetDateTime::now_utc().date(),
start_time: OffsetDateTime::now_utc().time(),
}
}
pub fn interval(mut self, interval: Duration) -> Self {
self.interval = Some(interval);
self
}
pub fn start_date(mut self, year: i32, month: u8, day: u8) -> Self {
self.start_date = Date::from_calendar_date(year, month.try_into().unwrap(), day).expect("Not a valid date.");
self
}
pub fn start_time(mut self, hour: u8, minute: u8, second: u8) -> Self {
self.start_time = Time::from_hms(hour, minute, second).expect("Not a valid time.");
self
}
}