pub struct WorkDay(/* private fields */);Expand description
Working hours on some days of the week.
On each local date whose weekday is in days, the rule makes the time
from start to end available for work. If end <= start, the shift is
overnight and ends on the next date, so start == end is a 24-hour shift.
A shift belongs to the day it starts on.
Times are wall-clock times in the rule’s time zone, which defaults to the schedule’s.
§Examples
use jiff::civil::time;
use workclock::{Weekdays, WorkDay};
let office = WorkDay::new(time(9, 0, 0, 0), time(17, 0, 0, 0), Weekdays::MON_TO_FRI);
let night = WorkDay::new(time(22, 0, 0, 0), time(6, 0, 0, 0), Weekdays::MON_TO_FRI)
.time_zone("Asia/Kolkata");Implementations§
Source§impl WorkDay
impl WorkDay
Sourcepub fn new(start: Time, end: Time, days: Weekdays) -> Self
pub fn new(start: Time, end: Time, days: Weekdays) -> Self
Creates a rule for start to end on days.
§Examples
use jiff::civil::time;
use jiff::{SignedDuration, Timestamp};
use workclock::{Schedule, Weekdays, WorkDay};
let night = WorkDay::new(time(22, 0, 0, 0), time(6, 0, 0, 0), Weekdays::MON_TO_FRI);
let schedule = Schedule::builder().rule(night).build()?;
let friday: Timestamp = "2026-01-09T22:00:00Z".parse()?;
let saturday: Timestamp = "2026-01-10T06:00:00Z".parse()?;
assert_eq!(schedule.between(friday, saturday), SignedDuration::from_hours(8));Trait Implementations§
impl Eq for WorkDay
impl StructuralPartialEq for WorkDay
Auto Trait Implementations§
impl Freeze for WorkDay
impl RefUnwindSafe for WorkDay
impl Send for WorkDay
impl Sync for WorkDay
impl Unpin for WorkDay
impl UnsafeUnpin for WorkDay
impl UnwindSafe for WorkDay
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more