Skip to main content

work_window_active

Function work_window_active 

Source
pub fn work_window_active(
    now: u32,
    start: u32,
    end: u32,
    today: u32,
    days_mask: u8,
) -> bool
Expand description

True iff the work window is open right now: the time-of-day is inside [start, end) and the relevant weekday’s bit is set in days_mask. today is days-since-Monday (0=Mon … 6=Sun), the same layout as the mask.

For a window that wraps past midnight (start > end, e.g. 22:00–06:00) the early-morning portion is gated on the day the window began — Friday’s 22:00 shift still covers Saturday 02:00 even when Saturday is off, and an off Sunday won’t start a window that bleeds into Monday morning. A window that doesn’t wrap is gated on today.

days_mask == 0 (no day enabled) always returns false; callers gate on work_window_enabled before reaching here, so that simply means the window never opens.