A law that changes on a date
The rule
Laws on working time change on a fixed date, often in steps. Chile’s working week, for example, is being cut from 45 hours to 40 over several years: 44 hours from 26 April 2024, 42 from 26 April 2026, 40 from 26 April 2028. Ordinary hours past the week are overtime. Each week must be worked out under the law in force that week: the weeks before a reform keep the old hours, the weeks after take the new.
Who uses it
Payroll and workforce software providers that keep each country’s rules up to date for all their customers, and any employer whose rules change on a date set in advance: a minimum-hours reform, a new overtime threshold, a collective agreement taking effect.
How the recipe does it
No Lua: the rule is a package (package.toml) of one layer, published
once for the install and adopted by every tenant it applies to.
name = "working_week_by_law"version = "1.0.0"
[[layer]]id = "working-week"locks = ["step:weekly"][[layer.step]]id = "weekly"uses = "standard/threshold"params = { over = "44h", to = "overtime", window = "week" }A reform is the package’s next version, with the day it takes effect:
version = "1.1.0"effective = "2026-04-26"hourctl attend pkg publish working_week_by_law --shared --effective 2026-04-26- A tenant following the major version (
hourctl -t acme attend pkg adopt working_week_by_law@1) takes each version as it is published. On each day the newest version in force that day applies: the weeks before 26 April keep 1.0.0, the weeks from it take 1.1.0, and every line’s stamps say which version’s layer gave its step ([[email protected]/working-week rev 1]). - Publishing a version works out again, from its effective day, every tenant that follows it. A closed pay period it reaches takes it as a late change (adjusted or refused, as the tenant’s policy says).
- A tenant pinning a version (
pkg pin [email protected]) keeps it, whatever is published after. locks = ["step:weekly"]keeps tenants from loosening the legal rule: a tenant’s layer that changes the step is refused. A tenant may still add its own steps beside it (a contract’s shorter week).
Parameters
| Setting | Meaning |
|---|---|
version, effective | Which version, and the workday it is in force from. |
locks | What no tenant’s layer may change. |
The weekly step’s over | The legal working week. |
What the scenarios show
a-43-hour-week-under-the-44-hour-law: 43 hours, no overtime.the-reform-applies-from-its-day: with 1.1.0 published in force from 26 April, the same 43 hours the week after have 1 hour of overtime, and the week before has none.a-tenant-pinning-the-old-version-keeps-it: pinned to 1.0.0, no overtime after the reform.a-tenant-cannot-loosen-the-law: a tenant’s layer changing the locked step is refused.
Legal note
A simplified form of the Chilean reform (Law 21.561), for illustration: it also allows averaging, sets how the reduction applies to particular schedules, and has exceptions. Check the law where you operate.
Get the recipe
The recipe’s package and its scenarios are in the example packages repository: attendance/working_week_by_law. 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 = "working_week_by_law"version = "1.0.0"description = "The legal working week as a shared package kept up to date as the law changes: ordinary hours past 44 a week are overtime, each later version in force from the day the law says."
# The ordinary working week the law sets: 44 hours. Time past it is# overtime (horas extraordinarias). A version published later, in force# from the day a reform takes effect, changes the hours from that day.[[layer]]id = "working-week"locks = ["step:weekly"][[layer.step]]id = "weekly"uses = "standard/threshold"params = { over = "44h", to = "overtime", window = "week" }Scenarios
Each scenario gives a person’s punches and setup and the timecard they must produce, worked out with this package adopted (the format).
Under the 44-hour week, 43 hours are all ordinary time
description = "Under the 44-hour week, 43 hours are all ordinary time"
punch = [ { at = "2026-04-13 08:00", kind = "in" }, { at = "2026-04-13 17:00", kind = "out" }, { at = "2026-04-14 08:00", kind = "in" }, { at = "2026-04-14 17:00", kind = "out" }, { at = "2026-04-15 08:00", kind = "in" }, { at = "2026-04-15 17:00", kind = "out" }, { at = "2026-04-16 08:00", kind = "in" }, { at = "2026-04-16 17:00", kind = "out" }, { at = "2026-04-27 08:00", kind = "in" }, { at = "2026-04-27 17:00", kind = "out" }, { at = "2026-04-28 08:00", kind = "in" }, { at = "2026-04-28 17:00", kind = "out" }, { at = "2026-04-29 08:00", kind = "in" }, { at = "2026-04-29 17:00", kind = "out" }, { at = "2026-04-30 08:00", kind = "in" }, { at = "2026-04-30 17:00", kind = "out" }, { at = "2026-04-17 08:00", kind = "in" }, { at = "2026-04-17 15:00", kind = "out" }, { at = "2026-05-01 08:00", kind = "in" }, { at = "2026-05-01 15:00", kind = "out" },]
[policy]zone = "America/Santiago"pay_periods = { every_days = 7, from = "2026-04-06" }
[expect.period]day = "2026-04-13"allocations = [ "2026-04-13 08:00-17:00 work 9.00", "2026-04-14 08:00-17:00 work 9.00", "2026-04-15 08:00-17:00 work 9.00", "2026-04-16 08:00-17:00 work 9.00", "2026-04-17 08:00-15:00 work 7.00",]The package locks its weekly step: a tenant's layer that would count overtime past 45 hours is refused, naming the package and the layer that lock it
description = "The package locks its weekly step: a tenant's layer that would count overtime past 45 hours is refused, naming the package and the layer that lock it"
punch = [ { at = "2026-04-13 08:00", kind = "in" }, { at = "2026-04-13 17:00", kind = "out" }, { at = "2026-04-14 08:00", kind = "in" }, { at = "2026-04-14 17:00", kind = "out" }, { at = "2026-04-15 08:00", kind = "in" }, { at = "2026-04-15 17:00", kind = "out" }, { at = "2026-04-16 08:00", kind = "in" }, { at = "2026-04-16 17:00", kind = "out" }, { at = "2026-04-27 08:00", kind = "in" }, { at = "2026-04-27 17:00", kind = "out" }, { at = "2026-04-28 08:00", kind = "in" }, { at = "2026-04-28 17:00", kind = "out" }, { at = "2026-04-29 08:00", kind = "in" }, { at = "2026-04-29 17:00", kind = "out" }, { at = "2026-04-30 08:00", kind = "in" }, { at = "2026-04-30 17:00", kind = "out" }, { at = "2026-04-17 08:00", kind = "in" }, { at = "2026-04-17 15:00", kind = "out" }, { at = "2026-05-01 08:00", kind = "in" }, { at = "2026-05-01 15:00", kind = "out" },]
[policy]zone = "America/Santiago"pay_periods = { every_days = 7, from = "2026-04-06" }
[[layer]]id = "lenient"[[layer.step]]id = "weekly"change = "params"params = { over = "45h" }
[expect]week = "2026-04-13"A tenant that pins version 1.0.0 is not moved to the reform when it is published: its week after the reform is still worked out at 44 hours. Following the major version (1) is what takes each version as it is published
description = "A tenant that pins version 1.0.0 is not moved to the reform when it is published: its week after the reform is still worked out at 44 hours. Following the major version (1) is what takes each version as it is published"
punch = [ { at = "2026-04-13 08:00", kind = "in" }, { at = "2026-04-13 17:00", kind = "out" }, { at = "2026-04-14 08:00", kind = "in" }, { at = "2026-04-14 17:00", kind = "out" }, { at = "2026-04-15 08:00", kind = "in" }, { at = "2026-04-15 17:00", kind = "out" }, { at = "2026-04-16 08:00", kind = "in" }, { at = "2026-04-16 17:00", kind = "out" }, { at = "2026-04-27 08:00", kind = "in" }, { at = "2026-04-27 17:00", kind = "out" }, { at = "2026-04-28 08:00", kind = "in" }, { at = "2026-04-28 17:00", kind = "out" }, { at = "2026-04-29 08:00", kind = "in" }, { at = "2026-04-29 17:00", kind = "out" }, { at = "2026-04-30 08:00", kind = "in" }, { at = "2026-04-30 17:00", kind = "out" }, { at = "2026-04-17 08:00", kind = "in" }, { at = "2026-04-17 15:00", kind = "out" }, { at = "2026-05-01 08:00", kind = "in" }, { at = "2026-05-01 15:00", kind = "out" },]
[policy]zone = "America/Santiago"pay_periods = { every_days = 7, from = "2026-04-06" }
# The reform: from 26 April 2026 the ordinary week is 42 hours, published# as the package's next version, in force from that day.[[published]]name = "working_week_by_law"version = "1.1.0"effective = "2026-04-26"[[published.layer]]id = "working-week"locks = ["step:weekly"][[published.layer.step]]id = "weekly"uses = "standard/threshold"params = { over = "42h", to = "overtime", window = "week" }
[adopt]working_week_by_law = "1.0.0"
[expect]week = "2026-04-27"allocations = [ "2026-04-27 08:00-17:00 work 9.00", "2026-04-28 08:00-17:00 work 9.00", "2026-04-29 08:00-17:00 work 9.00", "2026-04-30 08:00-17:00 work 9.00", "2026-05-01 08:00-15:00 work 7.00",]The package's next version, published with the reform in force from 26 April, makes the ordinary week 42 hours from that day. The same 43 hours the week after the reform have 1 hour of overtime, and the stamp names the version; the weeks before keep the version they had
description = "The package's next version, published with the reform in force from 26 April, makes the ordinary week 42 hours from that day. The same 43 hours the week after the reform have 1 hour of overtime, and the stamp names the version; the weeks before keep the version they had"
punch = [ { at = "2026-04-13 08:00", kind = "in" }, { at = "2026-04-13 17:00", kind = "out" }, { at = "2026-04-14 08:00", kind = "in" }, { at = "2026-04-14 17:00", kind = "out" }, { at = "2026-04-15 08:00", kind = "in" }, { at = "2026-04-15 17:00", kind = "out" }, { at = "2026-04-16 08:00", kind = "in" }, { at = "2026-04-16 17:00", kind = "out" }, { at = "2026-04-27 08:00", kind = "in" }, { at = "2026-04-27 17:00", kind = "out" }, { at = "2026-04-28 08:00", kind = "in" }, { at = "2026-04-28 17:00", kind = "out" }, { at = "2026-04-29 08:00", kind = "in" }, { at = "2026-04-29 17:00", kind = "out" }, { at = "2026-04-30 08:00", kind = "in" }, { at = "2026-04-30 17:00", kind = "out" }, { at = "2026-04-17 08:00", kind = "in" }, { at = "2026-04-17 15:00", kind = "out" }, { at = "2026-05-01 08:00", kind = "in" }, { at = "2026-05-01 15:00", kind = "out" },]
[policy]zone = "America/Santiago"pay_periods = { every_days = 7, from = "2026-04-06" }
# The reform: from 26 April 2026 the ordinary week is 42 hours, published# as the package's next version, in force from that day.[[published]]name = "working_week_by_law"version = "1.1.0"effective = "2026-04-26"[[published.layer]]id = "working-week"locks = ["step:weekly"][[published.layer.step]]id = "weekly"uses = "standard/threshold"params = { over = "42h", to = "overtime", window = "week" }
[expect]week = "2026-04-27"allocations = [ "2026-04-27 08:00-17:00 work 9.00", "2026-04-28 08:00-17:00 work 9.00", "2026-04-29 08:00-17:00 work 9.00", "2026-04-30 08:00-17:00 work 9.00", "2026-05-01 08:00-14:00 work 6.00", "2026-05-01 14:00-15:00 overtime 1.00",]stamps = ["2026-05-01 14:00-15:00 overtime: weekly [[email protected]/working-week rev 1]: moved 1h from work to overtime: over 42h in the week"]
[expect.period]day = "2026-04-13"allocations = [ "2026-04-13 08:00-17:00 work 9.00", "2026-04-14 08:00-17:00 work 9.00", "2026-04-15 08:00-17:00 work 9.00", "2026-04-16 08:00-17:00 work 9.00", "2026-04-17 08:00-15:00 work 7.00",]