Skip to content

Local time at each site

The rule

Rules by the time of day mean the local time where the work is done: a night premium from 22:00 is 22:00 on the clock at the site. Someone who works in Chicago on Monday and in Denver, an hour behind, on Wednesday has each day’s night hours counted by that site’s clock.

Who uses it

Field service, airlines and transport crews, construction, consultants and any employer whose people work at sites in several time zones: across the US, Canada, Australia, Mexico, Brazil, Russia, or Europe and the UK.

How the recipe does it

Configuration only, and no setting of the policy’s beyond its own zone: a work location has a time zone, and from the day a person is at a location their days are worked out in its zone. The package (package.toml) is one layer with a night premium, which follows the wall clock where the work is done:

[[layer]]
id = "sites"
[[layer.step]]
id = "night"
uses = "standard/window_premium"
params = { during = { daily = { from = "22:00", to = "06:00" } }, category = "night" }

The locations and the employment placing the person are the tenant’s setup:

[[location]]
id = "denver"
zone = "America/Denver"
[[employment]]
effective = "2026-10-07"
kind = "changed"
location = "denver"

Everything by the wall clock follows: where a workday starts (day_starts), the night premium’s period (standard/window_premium), rounding’s grid, ctx:at(date, "19:00") in a step of your own. A person at no location has the zone the policy gives (zone, and zones for a zone that changes from a day), and moving to or from a location works them out again from that day.

The clocks themselves need do nothing: a punch is an instant, and the engine reads it in the zone of its day.

Parameters

SettingMeaning
A location’s zoneThe zone days there are worked out in.
The policy’s zone and zonesThe zone of days at no location.

What the scenarios show

  • each-day-in-the-zone-of-its-site: Wednesday’s shift in Denver has 2 hours of night premium by Denver’s clock, though a Chicago clock would show 3.
  • without-a-site-the-setup-zone: at no location, the same shift is worked out in Chicago’s zone, with 3.

Where a law’s day or week is set by the employer’s establishment rather than the work site, model that instead. Check the rules where you operate.

Get the recipe

The recipe’s package and its scenarios are in the example packages repository: attendance/local_time_at_each_site. 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:

local_time_at_each_site/package.toml
name = "local_time_at_each_site"
version = "1.0.0"
description = "Each day is worked out in the time zone of the site the person works at that day, so rules by the wall clock (a night premium, a workday's start) follow the local clock wherever they work."
# Night premium: time between 22:00 and 06:00 on the wall clock where the
# work is done.
[[layer]]
id = "sites"
[[layer.step]]
id = "night"
uses = "standard/window_premium"
params = { during = { daily = { from = "22:00", to = "06:00" } }, category = "night" }

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 technician works Monday in Chicago and Wednesday in Denver, an hour behind. Each day is worked out in the zone of the site they work at that day: Wednesday's shift, 17:00 to 01:00 by a Chicago clock, is 16:00 to 24:00 in Denver, so it has 2 hours of night premium, as Monday's has, not 3
scenarios/each-day-in-the-zone-of-its-site.toml
description = "A technician works Monday in Chicago and Wednesday in Denver, an hour behind. Each day is worked out in the zone of the site they work at that day: Wednesday's shift, 17:00 to 01:00 by a Chicago clock, is 16:00 to 24:00 in Denver, so it has 2 hours of night premium, as Monday's has, not 3"
punch = [
{ at = "2026-10-05 16:00", kind = "in" }, { at = "2026-10-06 00:00", kind = "out" },
# The moments a clock in Chicago would show as 17:00 and 01:00.
{ at = "2026-10-07 17:00 -05:00", kind = "in" }, { at = "2026-10-08 01:00 -05:00", kind = "out" },
]
[policy]
zone = "America/Chicago"
[[location]]
id = "chicago"
zone = "America/Chicago"
[[location]]
id = "denver"
zone = "America/Denver"
[[employment]]
effective = "2026-01-05"
kind = "hired"
location = "chicago"
[[employment]]
effective = "2026-10-07"
kind = "changed"
location = "denver"
[expect]
week = "2026-10-05"
allocations = [
"2026-10-05 16:00-22:00 work 6.00",
"2026-10-05 22:00-2026-10-06 00:00 night 2.00",
"2026-10-07 16:00-22:00 work 6.00",
"2026-10-07 22:00-2026-10-08 00:00 night 2.00",
]
Someone at no work location has every day worked out in the zone of the policy: the same Wednesday shift is 17:00 to 01:00 on Chicago's clock, with 3 hours of night premium
scenarios/without-a-site-the-setup-zone.toml
description = "Someone at no work location has every day worked out in the zone of the policy: the same Wednesday shift is 17:00 to 01:00 on Chicago's clock, with 3 hours of night premium"
punch = [
{ at = "2026-10-07 17:00 -05:00", kind = "in" }, { at = "2026-10-08 01:00 -05:00", kind = "out" },
]
[policy]
zone = "America/Chicago"
[[location]]
id = "chicago"
zone = "America/Chicago"
[[location]]
id = "denver"
zone = "America/Denver"
[expect]
week = "2026-10-05"
allocations = [
"2026-10-07 17:00-22:00 work 5.00",
"2026-10-07 22:00-2026-10-08 01:00 night 3.00",
]