Overnight shifts: which workday the hours belong to
The rule
A shift from Monday evening to Tuesday morning crosses the start of a workday. Which day its hours belong to decides daily overtime, holiday premiums and which pay period pays them. Three rules are common:
- Whole to the day it starts (the default): the whole shift is Monday’s.
- Whole to the day it ends: the whole shift is Tuesday’s.
- Split at the workday’s start: the hours before midnight are Monday’s, the hours after are Tuesday’s.
Who uses it
- Start: most employers with night shifts; a shift is known by the day it started (“Monday night”).
- End: some payrolls that date a shift by when it was finished and paid.
- Split: employers whose daily overtime or holiday rules count hours in the fixed 24-hour workday they are worked in, and any workweek count, which must put hours in the week they were worked.
How the recipe does it
Configuration only: a package (package.toml) of one layer. The standard
attribute step, in the policy’s attribute stage, which runs before
rounding and allocation, splits shifts at midnight; then a daily
threshold puts time past 8 hours in overtime.
[[layer]]id = "overnight"[[layer.step]]id = "attribute"uses = "standard/attribute"params = { mode = "split" } # or "start" (the step's default) or "end"[[layer.step]]id = "daily"uses = "standard/threshold"params = { over = "8h", to = "overtime", window = "day" }A company that puts the whole shift on one day changes mode in a layer
of its own (change = "params").
The step calls ctx:attribute(id, mode) for each segment. With split,
the engine cuts a segment at each workday start it crosses (the policy’s
day_starts, midnight by default); the pieces are segments from then on,
each timed, allocated and approved in its own workday, and they always add
up to the shift. The cut is not a punch: rounding never moves it.
A company can write its own attribution step (for instance, split only
shifts that cross into a holiday) by calling ctx:attribute per segment.
Parameters
| Parameter | Meaning |
|---|---|
mode | "start", "end" or "split". |
why | Optional words for the ledger’s stamp. |
What the scenarios show
Each runs under a daily 8-hour threshold; the first three, the same two shifts:
whole-to-the-day-it-starts: Monday has 12 hours, 4 over.whole-to-the-day-it-ends: Tuesday has 16 hours, 8 over.split-at-midnight: Monday 6, Tuesday 10, 2 over.split-on-the-night-the-clocks-go-back: a 9-hour night by the clock that really passed, 2 hours on Saturday and 7 on Sunday.split-on-the-night-the-clocks-go-forward: 22:00 to 06:00 is 7 hours, 2 on Saturday and 5 on Sunday: the hour skipped was never worked.a-whole-night-the-clocks-go-back-pays-the-hour-repeated: kept whole, 20:00 to 06:00 is 11 hours worked, 3 of them overtime.a-whole-night-the-clocks-go-forward-pays-the-hours-worked: kept whole, 20:00 to 06:00 is 9 hours worked, 1 of them overtime.a-night-across-the-start-of-the-workweek: split at midnight, a Sunday night’s 2 hours are the first week’s (past its 40: overtime) and Monday’s 6 the next week’s.
A day is the hours actually worked in it, by the instants punched: a day the clocks go forward has 23 hours and one they go back 25, and a shift across either is paid what passed, never what the wall clock reads.
Legal note
This is a common way companies implement the workday of overnight shifts; check the rules where you operate. A workweek counts hours in the week they are worked, and a daily overtime rule counts them in the workday the employer has fixed.
Get the recipe
The recipe’s package and its scenarios are in the example packages repository: attendance/overnight_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 = "overnight_shifts"version = "1.0.0"description = "A shift that runs past the start of the next workday belongs whole to the day it starts, whole to the day it ends, or is split at the workday boundary, as the policy says."
# An overnight shift is cut at midnight, each piece its own workday's;# then time past 8 hours a day is overtime.[[layer]]id = "overnight"[[layer.step]]id = "attribute"uses = "standard/attribute"params = { mode = "split" }[[layer.step]]id = "daily"uses = "standard/threshold"params = { over = "8h", to = "overtime", window = "day" }Scenarios
Each scenario gives a person’s punches and setup and the timecard they must produce, worked out with this package adopted (the format).
40 hours Monday to Friday, then a night from Sunday 22:00 to Monday 06:00, split at midnight: Sunday's 2 hours are the first week's, past its 40, and overtime; Monday's 6 start the next week, straight time
description = "40 hours Monday to Friday, then a night from Sunday 22:00 to Monday 06:00, split at midnight: Sunday's 2 hours are the first week's, past its 40, and overtime; Monday's 6 start the next week, straight time"
punch = [ { at = "2026-10-05 08:00", kind = "in" }, { at = "2026-10-05 16:00", kind = "out" }, { at = "2026-10-06 08:00", kind = "in" }, { at = "2026-10-06 16:00", kind = "out" }, { at = "2026-10-07 08:00", kind = "in" }, { at = "2026-10-07 16:00", kind = "out" }, { at = "2026-10-08 08:00", kind = "in" }, { at = "2026-10-08 16:00", kind = "out" }, { at = "2026-10-09 08:00", kind = "in" }, { at = "2026-10-09 16:00", kind = "out" }, { at = "2026-10-11 22:00", kind = "in" }, { at = "2026-10-12 06:00", kind = "out" },]
[policy]zone = "America/Chicago"pay_periods = { every_days = 14, from = "2026-10-05" }week_starts = "monday"
# The company's weekly overtime besides the daily, counting straight time.[[layer]]id = "weekly"[[layer.step]]id = "weekly"uses = "standard/threshold"params = { over = "40h", to = "overtime", window = "week", counts = ["work"] }
[expect.period]day = "2026-10-05"allocations = [ "2026-10-05 08:00-16:00 work 8.00", "2026-10-06 08:00-16:00 work 8.00", "2026-10-07 08:00-16:00 work 8.00", "2026-10-08 08:00-16:00 work 8.00", "2026-10-09 08:00-16:00 work 8.00", "2026-10-11 22:00-2026-10-12 00:00 overtime 2.00", "2026-10-12 00:00-06:00 work 6.00",]Kept whole to the day it starts, a shift from 20:00 on October 31 to 06:00 on November 1 is 10 hours on the wall and 11 worked, the clocks going back an hour: 8 regular and 3 of daily overtime, the repeated hour paid
description = "Kept whole to the day it starts, a shift from 20:00 on October 31 to 06:00 on November 1 is 10 hours on the wall and 11 worked, the clocks going back an hour: 8 regular and 3 of daily overtime, the repeated hour paid"
punch = [ { at = "2026-10-31 20:00", kind = "in" }, { at = "2026-11-01 06:00", kind = "out" },]
[policy]zone = "America/Chicago"
[[layer]]id = "whole-to-the-start"[[layer.step]]id = "attribute"change = "params"params = { mode = "start" }
[expect]week = "2026-10-26"days = { "2026-10-31" = "11h" }allocations = [ "2026-10-31 20:00-2026-11-01 03:00 work 8.00", "2026-11-01 03:00-06:00 overtime 3.00",]Kept whole to the day it starts, a shift from 20:00 on March 7 to 06:00 on March 8 is 10 hours on the wall and 9 worked, the clocks going forward an hour: 8 regular and 1 of daily overtime, not 2
description = "Kept whole to the day it starts, a shift from 20:00 on March 7 to 06:00 on March 8 is 10 hours on the wall and 9 worked, the clocks going forward an hour: 8 regular and 1 of daily overtime, not 2"
punch = [ { at = "2026-03-07 20:00", kind = "in" }, { at = "2026-03-08 06:00", kind = "out" },]
[policy]zone = "America/Chicago"
[[layer]]id = "whole-to-the-start"[[layer.step]]id = "attribute"change = "params"params = { mode = "start" }
[expect]week = "2026-03-02"days = { "2026-03-07" = "9h" }allocations = [ "2026-03-07 20:00-2026-03-08 05:00 work 8.00", "2026-03-08 05:00-06:00 overtime 1.00",]Split at the workday's start (midnight): Monday keeps its 6 evening hours, Tuesday gets the 6 after midnight and its own evening's 4, 10 hours: the latest 2 are over the daily 8
description = "Split at the workday's start (midnight): Monday keeps its 6 evening hours, Tuesday gets the 6 after midnight and its own evening's 4, 10 hours: the latest 2 are over the daily 8"
punch = [ { at = "2026-10-05 18:00", kind = "in" }, { at = "2026-10-06 06:00", kind = "out" }, { at = "2026-10-06 18:00", kind = "in" }, { at = "2026-10-06 22:00", kind = "out" },]
[policy]zone = "America/Chicago"
[expect]week = "2026-10-05"days = { "2026-10-05" = "6h", "2026-10-06" = "10h" }segments = [ "work 2026-10-05 18:00-2026-10-06 00:00", "work 2026-10-06 00:00-06:00", "work 2026-10-06 18:00-22:00",]allocations = [ "2026-10-05 18:00-2026-10-06 00:00 work 6.00", "2026-10-06 00:00-06:00 work 6.00", "2026-10-06 18:00-20:00 work 2.00", "2026-10-06 20:00-22:00 overtime 2.00",]On the night the clocks go back (November 1, 2026), 22:00 to 06:00 on the wall is 9 hours. Split at midnight, Saturday has 2 and Sunday 7: the extra hour is in the workday it was worked in, and Sunday's 7 are under the daily 8
description = "On the night the clocks go back (November 1, 2026), 22:00 to 06:00 on the wall is 9 hours. Split at midnight, Saturday has 2 and Sunday 7: the extra hour is in the workday it was worked in, and Sunday's 7 are under the daily 8"
punch = [ { at = "2026-10-31 22:00", kind = "in" }, { at = "2026-11-01 06:00", kind = "out" },]
[policy]zone = "America/Chicago"
[expect]week = "2026-10-26"days = { "2026-10-31" = "2h", "2026-11-01" = "7h" }allocations = [ "2026-10-31 22:00-2026-11-01 00:00 work 2.00", "2026-11-01 00:00-06:00 work 7.00",]On the night the clocks go forward (March 8, 2026), 22:00 to 06:00 on the wall is 7 hours: the hour skipped was never worked. Split at midnight, Saturday has 2 and Sunday 5
description = "On the night the clocks go forward (March 8, 2026), 22:00 to 06:00 on the wall is 7 hours: the hour skipped was never worked. Split at midnight, Saturday has 2 and Sunday 5"
punch = [ { at = "2026-03-07 22:00", kind = "in" }, { at = "2026-03-08 06:00", kind = "out" },]
[policy]zone = "America/Chicago"
[expect]week = "2026-03-02"days = { "2026-03-07" = "2h", "2026-03-08" = "5h" }allocations = [ "2026-03-07 22:00-2026-03-08 00:00 work 2.00", "2026-03-08 00:00-06:00 work 5.00",]Whole to the workday it ends in: the same Monday night shift is all Tuesday's, with Tuesday evening's 4 hours, 16 hours in all: 8 regular and the latest 8 over the daily threshold. Monday has none
description = "Whole to the workday it ends in: the same Monday night shift is all Tuesday's, with Tuesday evening's 4 hours, 16 hours in all: 8 regular and the latest 8 over the daily threshold. Monday has none"
punch = [ { at = "2026-10-05 18:00", kind = "in" }, { at = "2026-10-06 06:00", kind = "out" }, { at = "2026-10-06 18:00", kind = "in" }, { at = "2026-10-06 22:00", kind = "out" },]
[policy]zone = "America/Chicago"
# A company that puts a whole shift on the day it ends.[[layer]]id = "day-it-ends"[[layer.step]]id = "attribute"change = "params"params = { mode = "end" }
[expect]week = "2026-10-05"days = { "2026-10-06" = "16h" }allocations = [ "2026-10-05 18:00-2026-10-06 02:00 work 8.00", "2026-10-06 02:00-06:00 overtime 4.00", "2026-10-06 18:00-22:00 overtime 4.00",]The default: a shift belongs whole to the workday it starts in. Monday 18:00 to Tuesday 06:00 is 12 hours of Monday (8 regular, 4 over the daily 8); Tuesday evening's 4 hours are Tuesday's
description = "The default: a shift belongs whole to the workday it starts in. Monday 18:00 to Tuesday 06:00 is 12 hours of Monday (8 regular, 4 over the daily 8); Tuesday evening's 4 hours are Tuesday's"
punch = [ { at = "2026-10-05 18:00", kind = "in" }, { at = "2026-10-06 06:00", kind = "out" }, { at = "2026-10-06 18:00", kind = "in" }, { at = "2026-10-06 22:00", kind = "out" },]
[policy]zone = "America/Chicago"
# A company that puts a whole shift on the day it starts.[[layer]]id = "day-it-starts"[[layer.step]]id = "attribute"change = "params"params = { mode = "start" }
[expect]week = "2026-10-05"days = { "2026-10-05" = "12h", "2026-10-06" = "4h" }allocations = [ "2026-10-05 18:00-2026-10-06 02:00 work 8.00", "2026-10-06 02:00-06:00 overtime 4.00", "2026-10-06 18:00-22:00 work 4.00",]