Shift differentials by the shift worked
The rule
A plant runs three shifts. Work on the evening shift earns 1.00 an hour more, and on the night shift 1.50, on top of its pay, for every hour of the shift, overtime hours included. What counts is the shift the person works, not the time of day: an evening shift that runs a little late is still all evening shift.
Who uses it
Manufacturing, warehousing, healthcare, call centres and utilities,
anywhere work runs around the clock, in any country: shift allowances,
“shift premiums”, night work supplements. Where the premium is by the
wall clock instead (every hour between 22:00 and 06:00), see the
cookbook’s night_differential.
How the recipe does it
The schedule says which shift is which. Each shift definition carries a
value, shift, and work matched to a shift takes the shift’s values into
its context:
[[shift_definition]]id = "evenings"start = "15:00"end = "23:00"days = ["monday", "tuesday", "wednesday", "thursday", "friday"]values = { shift = "evening" }The rule itself is configuration only: the package (package.toml) has
one layer for everyone with the standard allowance step, its amount by
the shift.
[[layer]]id = "differential"[[layer.step]]id = "differential"uses = "standard/allowance"params = { by = "shift", per_hour = { evening = 100, night = 150 }, pay = "differential", category = "shift_differential" }For each shift in per_hour, the pay period’s worked time on that shift
(work whose context value shift names it) earns that amount an hour, as
money in the money measure pay. Every worked category counts, so an
overtime hour on nights earns the differential as well as its overtime
premium. The money is worked out once for the period for each shift,
never hour by hour, and carries the shift in its context.
The differential is money beside the hours: the hours stay in their categories, so overtime and every other count is unchanged by it.
Which shift work belongs to is the engine’s matching: work starting
within a shift, or up to shifts.early before its start. Without
shifts.early, someone who starts 15 minutes before their shift is not
on it; with it, they are. For other ways to match work to shifts (the
nearest shift, a window after the start), see shift_matching.
What your setup needs
Set up before you adopt the recipe; the recipe’s steps read them by name, and adopting it is refused, with a list of what is missing, until they exist.
- A measure called
differential: the amount the recipe adds up (money in a currency, or a count).
The scenarios show each as it was set up for them.
Parameters
| Parameter | Meaning |
|---|---|
by | The context value that says which shift work is on (shift). |
per_hour | The amount an hour for each shift, in minor units: { evening = 100, night = 150 }. |
pay | The money measure the differential is added in. |
category | The category of the money lines (an earning code for payroll). |
What the scenarios show
an-evening-shift-earns-the-differential: 8 evening hours earn 8.00, the day shift nothing.overtime-on-nights-earns-it-too: 45 night hours, 5 of them overtime, all earn the night differential.a-paid-lunch-is-not-worked-and-earns-none: a paid lunch set up as not worked earns no differential; the 7 hours 30 minutes worked earn 7.50.an-early-start-is-not-the-shift-by-default: a start 15 minutes before the shift, withoutshifts.early, earns none.an-early-start-is-the-shift-with-shifts-early: withshifts.earlyat 30 minutes, the whole stretch earns it.
Legal note
Some jurisdictions require a night work premium or limit night hours, and some require shift premiums to be counted in the regular rate overtime is paid at. Check the rules where you operate.
Get the recipe
The recipe’s package and its scenarios are in the example packages repository: attendance/shift_differential. 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 = "shift_differential"version = "1.0.0"description = "Work on the evening shift earns 1.00 an hour more and on the night shift 1.50, overtime hours included, by the scheduled shift the work is on."
# What the tenant must have set up for the recipe: the steps read these by name.[needs]measures = ["differential"]
# Everyone: the pay period's worked time on each shift, by the shift's# value `shift`, earns that shift's amount an hour, as money beside the# hours.[[layer]]id = "differential"[[layer.step]]id = "differential"uses = "standard/allowance"params = { by = "shift", per_hour = { evening = 100, night = 150 }, pay = "differential", category = "shift_differential" }Scenarios
Each scenario gives a person’s punches and setup and the timecard they must produce, worked out with this package adopted (the format).
An evening shift with a paid 30-minute lunch the company counts as not worked: the lunch is paid, and only the 7 hours 30 minutes worked earn the differential, 7.50
description = "An evening shift with a paid 30-minute lunch the company counts as not worked: the lunch is paid, and only the 7 hours 30 minutes worked earn the differential, 7.50"
punch = [ { at = "2026-10-05 15:00", kind = "in" }, { at = "2026-10-05 19:00", kind = "lunch_start" }, { at = "2026-10-05 19:30", kind = "lunch_end" }, { at = "2026-10-05 23:00", kind = "out" },]
[policy]zone = "Europe/London"pay_periods = { every_days = 7, from = "2026-10-05" }categories = { lunch = "paid_lunch" }
[[measure]]id = "differential"kind = "money"currency = "GBP"
# Paid, but not worked: it counts toward no hours worked.[[category]]id = "paid_lunch"worked = false
[[shift_definition]]id = "evenings"start = "15:00"end = "23:00"days = ["monday", "tuesday", "wednesday", "thursday", "friday"]values = { shift = "evening" }
[expect]week = "2026-10-05"allocations = [ "2026-10-05 15:00-19:00 work 4.00 shift=evening", "2026-10-05 19:00-19:30 paid_lunch 0.50 shift=evening", "2026-10-05 19:30-23:00 work 3.50 shift=evening",]quantities = ["2026-10-05 differential 7.50 GBP shift_differential shift=evening"]Someone starts at 14:45 for Saturday's extra 15:00 evening shift. Without shifts.early, work that starts before a shift is not that shift's: it has no shift value and earns no differential
description = "Someone starts at 14:45 for Saturday's extra 15:00 evening shift. Without shifts.early, work that starts before a shift is not that shift's: it has no shift value and earns no differential"
punch = [ { at = "2026-10-10 14:45", kind = "in" }, { at = "2026-10-10 23:00", kind = "out" },]
[policy]zone = "Europe/London"pay_periods = { every_days = 7, from = "2026-10-05" }
[[measure]]id = "differential"kind = "money"currency = "GBP"
# The three shifts of the plant, each saying which it is.[[shift_definition]]id = "days"start = "07:00"end = "15:00"days = ["monday", "tuesday", "wednesday", "thursday", "friday"]values = { shift = "day" }
[[shift_definition]]id = "evenings"start = "15:00"end = "23:00"days = ["monday", "tuesday", "wednesday", "thursday", "friday"]values = { shift = "evening" }
[[shift_definition]]id = "nights"start = "23:00"end = "07:00"days = ["monday", "tuesday", "wednesday", "thursday", "friday"]values = { shift = "night" }
# An extra evening shift on Saturday, the only shift that day.[[shift]]id = "saturday-evening"start = "2026-10-10 15:00"end = "2026-10-10 23:00"values = { shift = "evening" }
[expect]week = "2026-10-05"allocations = ["2026-10-10 14:45-23:00 work 8.25"]quantities = []With shifts.early at 30 minutes, the same 14:45 start is the evening shift's: all 8.25 hours earn the differential, 8.25
description = "With shifts.early at 30 minutes, the same 14:45 start is the evening shift's: all 8.25 hours earn the differential, 8.25"
punch = [ { at = "2026-10-10 14:45", kind = "in" }, { at = "2026-10-10 23:00", kind = "out" },]
[policy]zone = "Europe/London"pay_periods = { every_days = 7, from = "2026-10-05" }shifts = { early = "30m" }
[[measure]]id = "differential"kind = "money"currency = "GBP"
# The three shifts of the plant, each saying which it is.[[shift_definition]]id = "days"start = "07:00"end = "15:00"days = ["monday", "tuesday", "wednesday", "thursday", "friday"]values = { shift = "day" }
[[shift_definition]]id = "evenings"start = "15:00"end = "23:00"days = ["monday", "tuesday", "wednesday", "thursday", "friday"]values = { shift = "evening" }
[[shift_definition]]id = "nights"start = "23:00"end = "07:00"days = ["monday", "tuesday", "wednesday", "thursday", "friday"]values = { shift = "night" }
# An extra evening shift on Saturday, the only shift that day.[[shift]]id = "saturday-evening"start = "2026-10-10 15:00"end = "2026-10-10 23:00"values = { shift = "evening" }
[expect]week = "2026-10-05"allocations = ["2026-10-10 14:45-23:00 work 8.25 shift=evening"]quantities = ["2026-10-10 differential 8.25 GBP shift_differential shift=evening"]Monday on the evening shift and Tuesday on the day shift: the 8 evening hours earn 1.00 each, 8.00 for the week; the day shift earns none
description = "Monday on the evening shift and Tuesday on the day shift: the 8 evening hours earn 1.00 each, 8.00 for the week; the day shift earns none"
punch = [ { at = "2026-10-05 15:00", kind = "in" }, { at = "2026-10-05 23:00", kind = "out" }, { at = "2026-10-06 07:00", kind = "in" }, { at = "2026-10-06 15:00", kind = "out" },]
[policy]zone = "Europe/London"pay_periods = { every_days = 7, from = "2026-10-05" }
[[measure]]id = "differential"kind = "money"currency = "GBP"
# The three shifts of the plant, each saying which it is.[[shift_definition]]id = "days"start = "07:00"end = "15:00"days = ["monday", "tuesday", "wednesday", "thursday", "friday"]values = { shift = "day" }
[[shift_definition]]id = "evenings"start = "15:00"end = "23:00"days = ["monday", "tuesday", "wednesday", "thursday", "friday"]values = { shift = "evening" }
[[shift_definition]]id = "nights"start = "23:00"end = "07:00"days = ["monday", "tuesday", "wednesday", "thursday", "friday"]values = { shift = "night" }
[expect]week = "2026-10-05"allocations = [ "2026-10-05 15:00-23:00 work 8.00 shift=evening", "2026-10-06 07:00-15:00 work 8.00 shift=day",]quantities = ["2026-10-05 differential 8.00 GBP shift_differential shift=evening"]Five 9-hour night shifts are 45 hours, the last 5 overtime: every one of the 45 hours earns the night differential of 1.50, 67.50, whatever category it is paid in
description = "Five 9-hour night shifts are 45 hours, the last 5 overtime: every one of the 45 hours earns the night differential of 1.50, 67.50, whatever category it is paid in"
punch = [ { at = "2026-10-05 23:00", kind = "in" }, { at = "2026-10-06 08:00", kind = "out" }, { at = "2026-10-06 23:00", kind = "in" }, { at = "2026-10-07 08:00", kind = "out" }, { at = "2026-10-07 23:00", kind = "in" }, { at = "2026-10-08 08:00", kind = "out" }, { at = "2026-10-08 23:00", kind = "in" }, { at = "2026-10-09 08:00", kind = "out" }, { at = "2026-10-09 23:00", kind = "in" }, { at = "2026-10-10 08:00", kind = "out" },]
[policy]zone = "Europe/London"pay_periods = { every_days = 7, from = "2026-10-05" }
[[measure]]id = "differential"kind = "money"currency = "GBP"
# The three shifts of the plant, each saying which it is.[[shift_definition]]id = "days"start = "07:00"end = "15:00"days = ["monday", "tuesday", "wednesday", "thursday", "friday"]values = { shift = "day" }
[[shift_definition]]id = "evenings"start = "15:00"end = "23:00"days = ["monday", "tuesday", "wednesday", "thursday", "friday"]values = { shift = "evening" }
[[shift_definition]]id = "nights"start = "23:00"end = "07:00"days = ["monday", "tuesday", "wednesday", "thursday", "friday"]values = { shift = "night" }
# The plant's own weekly overtime, before the differential: the hours it# makes overtime are on the night shift all the same.[[layer]]id = "weekly-overtime"order = 20[[layer.step]]id = "weekly"uses = "standard/threshold"params = { over = "40h", to = "overtime", window = "week" }before = "differential"
[expect]week = "2026-10-05"allocations = [ "2026-10-05 23:00-2026-10-06 08:00 work 9.00 shift=night", "2026-10-06 23:00-2026-10-07 08:00 work 9.00 shift=night", "2026-10-07 23:00-2026-10-08 08:00 work 9.00 shift=night", "2026-10-08 23:00-2026-10-09 08:00 work 9.00 shift=night", "2026-10-09 23:00-2026-10-10 03:00 work 4.00 shift=night", "2026-10-10 03:00-08:00 overtime 5.00 shift=night",]quantities = ["2026-10-09 differential 67.50 GBP shift_differential shift=night"]