Attribution by the scheduled shift
The rule
Which workday a shift’s hours belong to is a business rule. Without a rule, a segment is in the workday of its start punch, as punched. Some employers say instead that a shift belongs to the day it was scheduled for: the Monday 22:00 night shift is Monday’s work, whether the person punches in at 21:55 on Monday or at 00:05 on Tuesday.
Who uses it
- Employers with rostered night shifts, whose daily overtime, premiums and pay period follow the roster, not the punch.
- Those whose people punch in late or after midnight and must not move a shift to another day, or another pay period, by doing so.
How the recipe does it
Configuration only: a package (package.toml) of one layer with the standard
attribute_to_shift step, in the attribute stage.
[[layer]]id = "scheduled-shift-day"[[layer.step]]id = "attribute"uses = "standard/attribute_to_shift"params = { mode = "start" } # or "end" or "split", for work with no shiftThe step puts each segment that has a scheduled shift (matched as the policy’s
shifts settings and match steps say) in the workday that shift is of, by
ctx:attribute(id, { workday = date }). A segment with no shift matched to it
is attributed as mode says. The engine refuses a workday that is neither one
the segment touches nor its shift’s. The step declares nothing of how far a
shift’s work is from its day: it asks of the segments of the window
(ctx:segments(from, to)), and then of the days before and after it one at a
time (outward, on each side) while a day has work of a shift of the window, so a
shift of more than a day, or work that began the evening before it, is found. The
days it asked of are what the ledger looked at, so a punch that arrives late on
one of them redoes the earlier day. A day with none of the shift’s work ends the walk (a shift with a whole
day of no punches in the middle is found only as far as that day): a policy that needs more writes its own step.
Parameters
| Parameter | Meaning |
|---|---|
mode | For work with no scheduled shift: "start" (default), "end" or "split". |
why | Optional words for the ledger’s stamp. |
What the scenarios show
punched-after-midnight-is-the-shifts-day: the Monday night shift, punched in at 00:05 on Tuesday, is Monday’s.without-the-step-the-start-punch-decides: the same punches with the step disabled are Tuesday’s: the default.no-shift-matched-takes-the-mode: work on a night with no shift, the company’smodeofendputs it on the day it ends in.
Get the recipe
The recipe’s package and its scenarios are in the example packages repository: attendance/attribute_to_scheduled_shift. 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 = "attribute_to_scheduled_shift"version = "1.0.0"description = "A shift belongs to the workday its scheduled shift is of, wherever the person punched: a Monday night shift punched in after midnight is Monday's."
# Work matched to a scheduled shift is the workday the shift is of; work with no shift matched to it is attributed as# `mode` says (the day it starts in, unless a layer of the company's says otherwise).[[layer]]id = "scheduled-shift-day"[[layer.step]]id = "attribute"uses = "standard/attribute_to_shift"params = { mode = "start" }Scenarios
Each scenario gives a person’s punches and setup and the timecard they must produce, worked out with this package adopted (the format).
As the shift of 36 hours without a match step, with the `match` step choosing among the shifts of the days back: A 36 hour shift, Monday 18:00 to Wednesday 06:00, worked Monday 18:00 to Tuesday 10:00 and again from Wednesday 00:05 to 06:00: the work two workdays on is still the shift's day, Monday's: 16 hours and 5 hours 55 minutes on Monday, none on Wednesday
description = "As the shift of 36 hours without a match step, with the `match` step choosing among the shifts of the days back: A 36 hour shift, Monday 18:00 to Wednesday 06:00, worked Monday 18:00 to Tuesday 10:00 and again from Wednesday 00:05 to 06:00: the work two workdays on is still the shift's day, Monday's: 16 hours and 5 hours 55 minutes on Monday, none on Wednesday"
punch = [ { at = "2026-10-05 18:00", kind = "in" }, { at = "2026-10-06 10:00", kind = "out" }, { at = "2026-10-07 00:05", kind = "in" }, { at = "2026-10-07 06:00", kind = "out" },]
[policy]zone = "America/Chicago"
[[policy.step]]id = "match"uses = "standard/match"params = { prefer = "nearest" }
[[shift]]id = "long"start = "2026-10-05 18:00"end = "2026-10-07 06:00"
[expect]week = "2026-10-05"days = { "2026-10-05" = "21h55m" }A 36 hour shift, Monday 18:00 to Wednesday 06:00, worked Monday 18:00 to Tuesday 10:00 and again from Wednesday 00:05 to 06:00: the work two workdays on is still the shift's day, Monday's: 16 hours and 5 hours 55 minutes on Monday, none on Wednesday
description = "A 36 hour shift, Monday 18:00 to Wednesday 06:00, worked Monday 18:00 to Tuesday 10:00 and again from Wednesday 00:05 to 06:00: the work two workdays on is still the shift's day, Monday's: 16 hours and 5 hours 55 minutes on Monday, none on Wednesday"
punch = [ { at = "2026-10-05 18:00", kind = "in" }, { at = "2026-10-06 10:00", kind = "out" }, { at = "2026-10-07 00:05", kind = "in" }, { at = "2026-10-07 06:00", kind = "out" },]
[policy]zone = "America/Chicago"
[[shift]]id = "long"start = "2026-10-05 18:00"end = "2026-10-07 06:00"
[expect]week = "2026-10-05"days = { "2026-10-05" = "21h55m" }Work on a night with no scheduled shift is attributed as the step's mode says: the default puts Wednesday 22:00 to Thursday 06:00 on Wednesday, a company's layer that changes `mode` to `end` puts it on Thursday, while Monday's scheduled night stays Monday's
description = "Work on a night with no scheduled shift is attributed as the step's mode says: the default puts Wednesday 22:00 to Thursday 06:00 on Wednesday, a company's layer that changes `mode` to `end` puts it on Thursday, while Monday's scheduled night stays Monday's"
punch = [ { at = "2026-10-06 00:05", kind = "in" }, { at = "2026-10-06 06:00", kind = "out" }, { at = "2026-10-07 22:00", kind = "in" }, { at = "2026-10-08 06:00", kind = "out" },]
[policy]zone = "America/Chicago"
[[shift_definition]]id = "nights"start = "22:00"end = "06:00"days = ["monday"]
# A company that dates an unscheduled night by the day it ends.[[layer]]id = "unscheduled-by-end"[[layer.step]]id = "attribute"change = "params"params = { mode = "end" }
[expect]week = "2026-10-05"days = { "2026-10-05" = "5h55m", "2026-10-08" = "8h" }The Monday 22:00 to 06:00 night shift, punched in at 00:05 on Tuesday and out at 06:00, is all Monday's: 5 hours 55 minutes on Monday and none on Tuesday
description = "The Monday 22:00 to 06:00 night shift, punched in at 00:05 on Tuesday and out at 06:00, is all Monday's: 5 hours 55 minutes on Monday and none on Tuesday"
punch = [ { at = "2026-10-06 00:05", kind = "in" }, { at = "2026-10-06 06:00", kind = "out" },]
[policy]zone = "America/Chicago"
[[shift_definition]]id = "nights"start = "22:00"end = "06:00"days = ["monday"]
[expect]week = "2026-10-05"days = { "2026-10-05" = "5h55m" }The same punches with the step disabled by a layer of the company's: with no attribute step a segment is in the workday of its start punch, as punched, so the night is Tuesday's
description = "The same punches with the step disabled by a layer of the company's: with no attribute step a segment is in the workday of its start punch, as punched, so the night is Tuesday's"
punch = [ { at = "2026-10-06 00:05", kind = "in" }, { at = "2026-10-06 06:00", kind = "out" },]
[policy]zone = "America/Chicago"
[[shift_definition]]id = "nights"start = "22:00"end = "06:00"days = ["monday"]
# A company with no rule about it: the default holds.[[layer]]id = "no-rule"[[layer.step]]id = "attribute"change = "disable"
[expect]week = "2026-10-05"days = { "2026-10-06" = "5h55m" }