pub enum Schedule {
Hours {
start_hour: u8,
end_hour: u8,
use_local_tz: bool,
},
Weekdays {
use_local_tz: bool,
},
Weekends {
use_local_tz: bool,
},
Custom(Arc<dyn Fn(DateTime<Utc>) -> bool + Send + Sync>),
}Expand description
A time-based schedule for constraint checking.
Variants§
Hours
Business hours (e.g., 9am-5pm).
When use_local_tz is true, hours are interpreted in the system’s local timezone.
When false, hours are interpreted in UTC.
Weekdays
Monday through Friday.
When use_local_tz is true, weekday is determined in the system’s local timezone.
When false, weekday is determined in UTC.
Weekends
Saturday and Sunday.
When use_local_tz is true, weekday is determined in the system’s local timezone.
When false, weekday is determined in UTC.
Custom(Arc<dyn Fn(DateTime<Utc>) -> bool + Send + Sync>)
Custom schedule using a closure.
Implementations§
Source§impl Schedule
impl Schedule
Sourcepub fn hours(start_hour: u8, end_hour: u8) -> Result<Self>
pub fn hours(start_hour: u8, end_hour: u8) -> Result<Self>
Create a business hours schedule (UTC).
For local timezone-aware schedules, use hours_local_tz().
§Errors
Returns an error if:
start_houris greater than 23end_houris greater than 23start_houris greater than or equal toend_hour
§Examples
use tiny_counter::Schedule;
let schedule = Schedule::hours(9, 17).unwrap(); // 9am-5pm UTC
let schedule = Schedule::hours(6, 22).unwrap(); // 6am-10pm UTC
let schedule = Schedule::hours_local_tz(9, 17).unwrap(); // 9am-5pm local timeSourcepub fn hours_local_tz(start_hour: u8, end_hour: u8) -> Result<Self>
pub fn hours_local_tz(start_hour: u8, end_hour: u8) -> Result<Self>
Create a business hours schedule using the system’s local timezone.
§Errors
Returns an error if:
start_houris greater than 23end_houris greater than 23start_houris greater than or equal toend_hour
§Examples
use tiny_counter::Schedule;
let schedule = Schedule::hours_local_tz(9, 17).unwrap(); // 9am-5pm in system's local timezoneSourcepub fn weekdays_local_tz() -> Self
pub fn weekdays_local_tz() -> Self
Create a weekdays schedule using the system’s local timezone.
Sourcepub fn weekends_local_tz() -> Self
pub fn weekends_local_tz() -> Self
Create a weekends schedule using the system’s local timezone.