Too little rest between shifts
The rule
Between the end of one shift and the start of the next, a person must have at least a set rest period: 8, 10 or 11 hours are common. A shift that starts sooner is flagged, for scheduling to fix and, where the rule pays a premium for it, for payroll.
Who uses it
Hospitals and care homes (fatigue and patient safety), transport and logistics, and employers under predictive scheduling ordinances or collective agreements that pay a premium for “clopening” shifts (closing late, then opening early).
How the recipe does it
Configuration only: a package (package.toml) of one layer. The standard
attribute step cuts overnight shifts at midnight, and the standard
rest step checks the rest before each day’s first work.
[[layer]]id = "rest"[[layer.step]]id = "split"uses = "standard/attribute"params = { mode = "split" }[[layer.step]]id = "rest"uses = "standard/rest"params = { at_least = "10h" }rest runs on each workday with work. It reads ctx.previous_end, when
the last segment of an earlier workday ended (of the pay period before too,
as punched, for its first workday), and the day’s first work segment
(ctx.segments). If the first work starts less than at_least after that
end, it raises rest_too_short about that work. Work going on across the
workday’s start (the piece of an overnight shift split at midnight by
standard/attribute) is no new start: no rest is asked of it, and the rest
is counted from its end, so a shift later that day is checked.
Raw punch times are used, never rounded ones.
On clocks where a lunch is an out and an in (BrightLink), the gap between them
is two shifts to this step: the in after it is a start whose rest is asked.
Take the gap as a lunch with standard/gap_lunch (within = the longest
lunch) before this step, and the work runs on as one shift (the recipe
lunch_from_out_and_in).
Parameters
| Parameter | Meaning |
|---|---|
at_least | The rest asked between shifts: "10h". |
What the scenarios show
exactly-ten-hours-and-a-minute-short: exactly 10 hours of rest is enough; 9 hours 59 minutes is not.work-across-midnight-is-no-new-start: an overnight shift split at midnight asks no rest of its second piece; the next real start does.a-lunch-after-midnight-is-no-new-start: work that goes on after a lunch of the same overnight shift is no new start either.an-in-that-never-ends-is-a-start-of-work: a shift begun with an in that never ends is a start, and its rest is asked.work-after-a-lunch-that-never-ends-asks-no-rest-again: work that goes on after a lunch with no end has no end to count rest from, so the rest of that workday asks none (the missing out says what is wrong).a-stray-lunch-is-flagged-and-starts-no-shift: a lunch with no work before it is flagged at its punches and paired into nothing (pairing flags a break or lunch punch that fits nothing and makes no work from it), so there is no start to check rest for.a-split-day-checks-only-its-first-startanda-night-split-checks-the-first-start-after-the-shift: only the first start of a workday is checked, for the day worker and the night worker alike.the-period-before-counts: the first shift of a weekly pay period, 7 hours after the last one of the period before, is short of rest.
Legal note
This is a common way companies implement minimum rest between shifts; check the rules where you operate. Some rules count rest from the scheduled shifts rather than the punches, or pay a premium instead of forbidding the short rest.
Get the recipe
The recipe’s package and its scenarios are in the example packages repository: attendance/rest_between_shifts. Test it, or your own copy of it, with hourctl attend test, and publish it with hourctl attend pkg publish.
The policy package
The package’s layers, with the standard steps each one runs and their settings:
name = "rest_between_shifts"version = "1.0.0"description = "An exception when a shift starts less than a set time, such as 10 hours, after the last one ended."
# Overnight shifts are cut at midnight; then the first work of a day# starting less than 10 hours after the last work before it ended is# flagged (rest_too_short).[[layer]]id = "rest"[[layer.step]]id = "split"uses = "standard/attribute"params = { mode = "split" }[[layer.step]]id = "rest"uses = "standard/rest"params = { at_least = "10h" }Scenarios
Each scenario gives a person’s punches and setup and the timecard they must produce, worked out with this package adopted (the format).
A lunch taken after midnight in an overnight shift is part of that shift: Monday 22:00 to Tuesday 06:00 with lunch from 01:00 to 01:30 asks no rest of the work after the lunch (the shift is not new), and Tuesday's own evening shift is checked as before
description = "A lunch taken after midnight in an overnight shift is part of that shift: Monday 22:00 to Tuesday 06:00 with lunch from 01:00 to 01:30 asks no rest of the work after the lunch (the shift is not new), and Tuesday's own evening shift is checked as before"
punch = [ { at = "2026-10-05 22:00", kind = "in" }, { at = "2026-10-06 01:00", kind = "lunch_start" }, { at = "2026-10-06 01:30", kind = "lunch_end" }, { at = "2026-10-06 06:00", kind = "out" }, { at = "2026-10-06 18:00", kind = "in" }, { at = "2026-10-06 23:00", kind = "out" }, { at = "2026-10-07 08:00", kind = "in" }, { at = "2026-10-07 16:00", kind = "out" },]
[policy]zone = "America/Chicago"
[expect]week = "2026-10-05"exceptions = [{ kind = "rest_too_short", at = "2026-10-07 08:00" }]An overnight shift with a lunch after midnight asks no rest of the work after the lunch; the first new start of Tuesday is the 14:00 in, 8 hours after the shift ended at 06:00: too little rest. The day worker's split piece raises nothing because it is not the day's first start; this one is, as the day began with the shift going on
description = "An overnight shift with a lunch after midnight asks no rest of the work after the lunch; the first new start of Tuesday is the 14:00 in, 8 hours after the shift ended at 06:00: too little rest. The day worker's split piece raises nothing because it is not the day's first start; this one is, as the day began with the shift going on"
punch = [ { at = "2026-10-05 22:00", kind = "in" }, { at = "2026-10-06 02:00", kind = "lunch_start" }, { at = "2026-10-06 02:30", kind = "lunch_end" }, { at = "2026-10-06 06:00", kind = "out" }, { at = "2026-10-06 14:00", kind = "in" }, { at = "2026-10-06 18:00", kind = "out" },]
[policy]zone = "America/Chicago"
[expect]week = "2026-10-05"exceptions = [{ kind = "rest_too_short", at = "2026-10-06 14:00" }]A day worker's second piece of the day is no start that is checked: Monday 06:00 to 10:00 and 14:00 to 18:00 have 4 hours between them and raise nothing. Tuesday 06:00 is 12 hours after Monday's last end
description = "A day worker's second piece of the day is no start that is checked: Monday 06:00 to 10:00 and 14:00 to 18:00 have 4 hours between them and raise nothing. Tuesday 06:00 is 12 hours after Monday's last end"
punch = [ { at = "2026-10-05 06:00", kind = "in" }, { at = "2026-10-05 10:00", kind = "out" }, { at = "2026-10-05 14:00", kind = "in" }, { at = "2026-10-05 18:00", kind = "out" }, { at = "2026-10-06 06:00", kind = "in" }, { at = "2026-10-06 14:00", kind = "out" },]
[policy]zone = "America/Chicago"
[expect]week = "2026-10-05"exceptions = []A lunch that begins with no work before it (a stray press) is flagged at its punches and plays no part in pairing: the lunch's end starts no work, so nothing here is a shift to check rest for. Monday's shift ends at 22:00; Tuesday's lunch punches 04:55 to 05:25 and an out at 12:00 are each flagged, and no work or lunch time is made from them
description = "A lunch that begins with no work before it (a stray press) is flagged at its punches and plays no part in pairing: the lunch's end starts no work, so nothing here is a shift to check rest for. Monday's shift ends at 22:00; Tuesday's lunch punches 04:55 to 05:25 and an out at 12:00 are each flagged, and no work or lunch time is made from them"
punch = [ { at = "2026-10-05 14:00", kind = "in" }, { at = "2026-10-05 22:00", kind = "out" }, { at = "2026-10-06 04:55", kind = "lunch_start" }, { at = "2026-10-06 05:25", kind = "lunch_end" }, { at = "2026-10-06 12:00", kind = "out" },]
[policy]zone = "America/Chicago"
[expect]week = "2026-10-05"exceptions = [{ kind = "missing_in", at = "2026-10-06 04:55" }, { kind = "missing_in", at = "2026-10-06 12:00" }, { kind = "missing_lunch_start", at = "2026-10-06 05:25" }]A shift that begins with an in and never ends is still a start of work, and its rest is asked: Monday's work ended at 16:00, and Tuesday 01:00 is 9 hours later
description = "A shift that begins with an in and never ends is still a start of work, and its rest is asked: Monday's work ended at 16:00, and Tuesday 01:00 is 9 hours later"
punch = [ { at = "2026-10-05 08:00", kind = "in" }, { at = "2026-10-05 16:00", kind = "out" }, { at = "2026-10-06 01:00", kind = "in" },]
[policy]zone = "America/Chicago"
[expect]week = "2026-10-05"exceptions = [{ kind = "rest_too_short", at = "2026-10-06 01:00" }]At least 10 hours between shifts: out Monday at 22:00 and in Tuesday at 08:00 is exactly 10 hours, enough; out Tuesday at 22:00 and in Wednesday at 07:59 is a minute short, an exception about Wednesday's work
description = "At least 10 hours between shifts: out Monday at 22:00 and in Tuesday at 08:00 is exactly 10 hours, enough; out Tuesday at 22:00 and in Wednesday at 07:59 is a minute short, an exception about Wednesday's work"
punch = [ { at = "2026-10-05 12:00", kind = "in" }, { at = "2026-10-05 22:00", kind = "out" }, { at = "2026-10-06 08:00", kind = "in" }, { at = "2026-10-06 22:00", kind = "out" }, { at = "2026-10-07 07:59", kind = "in" }, { at = "2026-10-07 16:00", kind = "out" },]
[policy]zone = "America/Chicago"
[expect]week = "2026-10-05"exceptions = [{ kind = "rest_too_short", at = "2026-10-07 07:59" }]Paid weekly, from Monday. Sunday's shift, the last of one pay period, ends at 23:00; Monday's, the first of the next, starts at 06:00: 7 hours of rest, short, though the two shifts are in different pay periods. Tuesday's 06:00 start after Monday's 14:00 end is 16 hours, enough
description = "Paid weekly, from Monday. Sunday's shift, the last of one pay period, ends at 23:00; Monday's, the first of the next, starts at 06:00: 7 hours of rest, short, though the two shifts are in different pay periods. Tuesday's 06:00 start after Monday's 14:00 end is 16 hours, enough"
punch = [ { at = "2026-10-04 15:00", kind = "in" }, { at = "2026-10-04 23:00", kind = "out" }, { at = "2026-10-05 06:00", kind = "in" }, { at = "2026-10-05 14:00", kind = "out" }, { at = "2026-10-06 06:00", kind = "in" }, { at = "2026-10-06 14:00", kind = "out" },]
[policy]zone = "America/Chicago"
[expect]week = "2026-10-05"exceptions = [{ kind = "rest_too_short", at = "2026-10-05 06:00" }]Overnight shifts split at midnight: Monday 22:00 to Tuesday 06:00 goes on across Tuesday's start, which is no new shift, so no rest is asked of it. Tuesday's evening shift ends at 23:00, and Wednesday's starts nine hours later: too little rest
description = "Overnight shifts split at midnight: Monday 22:00 to Tuesday 06:00 goes on across Tuesday's start, which is no new shift, so no rest is asked of it. Tuesday's evening shift ends at 23:00, and Wednesday's starts nine hours later: too little rest"
punch = [ { at = "2026-10-05 22:00", kind = "in" }, { at = "2026-10-06 06:00", kind = "out" }, { at = "2026-10-06 18:00", kind = "in" }, { at = "2026-10-06 23:00", kind = "out" }, { at = "2026-10-07 08:00", kind = "in" }, { at = "2026-10-07 16:00", kind = "out" },]
[policy]zone = "America/Chicago"
[expect]week = "2026-10-05"exceptions = [{ kind = "rest_too_short", at = "2026-10-07 08:00" }]Work that goes on after a lunch and never ends has no end to count rest from: the in 3 hours later is the same shift pressed again (the missing out says so), and asks no rest of the rest of that workday
description = "Work that goes on after a lunch and never ends has no end to count rest from: the in 3 hours later is the same shift pressed again (the missing out says so), and asks no rest of the rest of that workday"
punch = [ { at = "2026-10-05 22:00", kind = "in" }, { at = "2026-10-06 00:20", kind = "lunch_start" }, { at = "2026-10-06 00:50", kind = "lunch_end" }, { at = "2026-10-06 03:50", kind = "in" }, { at = "2026-10-06 04:30", kind = "out" },]
[policy]zone = "America/Chicago"
[expect]week = "2026-10-05"exceptions = [{ kind = "missing_out", at = "2026-10-06 00:50" }]