Skip to content

Exact time in decimal hours

The rule

Payroll pays decimal hours (8.25, or tenths: 8.3), but time is worked in minutes and seconds: 20 minutes is 0.333… of an hour, which no number of decimals holds. Rounding each line on its own loses or makes time: three 20-minute stretches rounded to 0.33 each are 0.99 hours, not 1.00. The rule is that what is paid adds up to the time worked, line by line and in total, and that every rule (overtime, minimums) is decided on the exact time, never on the decimals.

Who uses it

Everyone who pays by the hour. It matters most where hours are audited against punches (unions, wage-and-hour claims) and wherever a payroll system imports hours in tenths or hundredths.

How the recipe does it

Configuration only: how time becomes decimal hours is the engine’s own, and a policy chooses only how many decimals (decimals, 0 to 9; 2 without it). The package (package.toml) is one layer of two decimals, with a weekly overtime threshold past 40 hours to show that overtime is decided on exact time:

[[layer]]
id = "hours"
settings = { decimals = 2 }
[[layer.step]]
id = "weekly"
uses = "standard/threshold"
params = { over = "40h", to = "overtime", window = "week" }

The engine keeps the time worked so far exact, in nanoseconds. Each line, in the order lines are paid (as their time started), is given the whole steps of the time so far not yet given (0.01 of an hour at two decimals); what is left over, less than a step, is carried forward to the next line, where it counts. So:

  • the lines always add up to the whole steps of all the time: three 20-minute stretches are 0.33, 0.33 and 0.34, exactly 1.00;
  • no line is more than one step from its own time;
  • what is still carried at the end is less than one step (under 36 seconds at two decimals);
  • the same time always gives the same lines.

Thresholds read exact time: five days of 8 hours 4 minutes are 40 hours 20 minutes, and exactly 20 minutes are overtime, whatever the lines show.

Rounding punches (to the quarter hour, the tenth of an hour) is a separate choice, made on the times themselves before anything is counted: see seven_minute_rounding, tenth_hour_rounding and rounding_without_meals. Grace at the start of a shift is snap_to_schedule (paid from the shift’s start) or late_and_early (late only after a grace).

Parameters

SettingMeaning
decimalsHow many decimals hours are shown in, 0 to 9 (default 2).

What the scenarios show

  • three-twenty-minute-stretches-are-one-hour: 0.33, 0.33 and 0.34 are 1.00.
  • tenths-of-an-hour: a company paying in tenths of an hour (its own layer sets decimals = 1): the same at one decimal, 0.3, 0.3 and 0.4.
  • overtime-is-decided-on-exact-time: 40 hours 20 minutes, exactly 20 minutes of overtime.

Paying exact time is the safest practice wherever wage-and-hour law requires all time worked to be paid; check how your payroll provider takes hours, and the rules where you operate.

Get the recipe

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

decimal_hours/package.toml
name = "decimal_hours"
version = "1.0.0"
description = "Time is kept exact and shown in the decimal hours payroll takes, two decimals or tenths, with nothing lost or made by rounding line by line."
# Hours in two decimals, and time past 40 hours a week is overtime,
# decided on the exact time worked.
[[layer]]
id = "hours"
settings = { decimals = 2 }
[[layer.step]]
id = "weekly"
uses = "standard/threshold"
params = { over = "40h", 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).

Five days of 8 hours 4 minutes are 40 hours 20 minutes. The weekly threshold is decided on exact time, not on decimal hours: exactly 20 minutes are overtime, shown as 0.33, and the week as 40.33
scenarios/overtime-is-decided-on-exact-time.toml
description = "Five days of 8 hours 4 minutes are 40 hours 20 minutes. The weekly threshold is decided on exact time, not on decimal hours: exactly 20 minutes are overtime, shown as 0.33, and the week as 40.33"
punch = [
{ at = "2026-10-05 08:00", kind = "in" }, { at = "2026-10-05 16:04", kind = "out" },
{ at = "2026-10-06 08:00", kind = "in" }, { at = "2026-10-06 16:04", kind = "out" },
{ at = "2026-10-07 08:00", kind = "in" }, { at = "2026-10-07 16:04", kind = "out" },
{ at = "2026-10-08 08:00", kind = "in" }, { at = "2026-10-08 16:04", kind = "out" },
{ at = "2026-10-09 08:00", kind = "in" }, { at = "2026-10-09 16:04", kind = "out" },
]
[policy]
zone = "America/Chicago"
[expect]
week = "2026-10-05"
worked = "40h 20m"
paid = "40.33"
allocations = [
"2026-10-05 08:00-16:04 work 8.06",
"2026-10-06 08:00-16:04 work 8.07",
"2026-10-07 08:00-16:04 work 8.07",
"2026-10-08 08:00-16:04 work 8.06",
"2026-10-09 08:00-15:44 work 7.74",
"2026-10-09 15:44-16:04 overtime 0.33",
]
The same three stretches at one decimal, as a payroll that takes tenths of an hour reads them: 0.3, 0.3 and 0.4, and the day 1.0
scenarios/tenths-of-an-hour.toml
description = "The same three stretches at one decimal, as a payroll that takes tenths of an hour reads them: 0.3, 0.3 and 0.4, and the day 1.0"
punch = [
{ at = "2026-10-05 08:00", kind = "in" }, { at = "2026-10-05 08:20", kind = "out" },
{ at = "2026-10-05 09:00", kind = "in" }, { at = "2026-10-05 09:20", kind = "out" },
{ at = "2026-10-05 10:00", kind = "in" }, { at = "2026-10-05 10:20", kind = "out" },
]
[policy]
zone = "America/Chicago"
# A company paying in tenths of an hour.
[[layer]]
id = "tenths"
settings = { decimals = 1 }
[expect]
week = "2026-10-05"
paid = "1.0"
lines = ["0.3", "0.3", "0.4"]
Three stretches of 20 minutes are an hour. At two decimals each is a third of an hour, 0.333...; the engine carries what each line leaves over to the next, so the lines show 0.33, 0.33 and 0.34 and the day exactly 1.00, never 0.99
scenarios/three-twenty-minute-stretches-are-one-hour.toml
description = "Three stretches of 20 minutes are an hour. At two decimals each is a third of an hour, 0.333...; the engine carries what each line leaves over to the next, so the lines show 0.33, 0.33 and 0.34 and the day exactly 1.00, never 0.99"
punch = [
{ at = "2026-10-05 08:00", kind = "in" }, { at = "2026-10-05 08:20", kind = "out" },
{ at = "2026-10-05 09:00", kind = "in" }, { at = "2026-10-05 09:20", kind = "out" },
{ at = "2026-10-05 10:00", kind = "in" }, { at = "2026-10-05 10:20", kind = "out" },
]
[policy]
zone = "America/Chicago"
[expect]
week = "2026-10-05"
worked = "1h 0m"
paid = "1.00"
lines = ["0.33", "0.33", "0.34"]