Skip to content

Double punches and stepping out a moment

The rule

Two cleanups of the punches themselves, before they are paired into work:

  • Lockout: a punch within a couple of minutes of the one before it, of the same kind, is the same punch twice (the badge was swiped again, the clock did not beep). It is ignored.
  • Joining short gaps: an out followed within a few minutes by an in is not a break in the work (stepping out to move a car, a clock at the other door). Both punches are ignored and the work runs on.

Without them a double swipe leaves one in without its out, and a short step out cuts the day in two (a few unpaid minutes, and overtime counted from a new start where a rule counts consecutive hours).

Who uses it

Anyone with badge or biometric clocks: warehouses, plants, hospitals. Clock vendors usually offer a lockout on the device; doing it in the policy keeps every punch as recorded (nothing is thrown away) and stamps which ones were set aside, and why.

How the recipe does it

Configuration only: a package (package.toml) of one layer running the standard lockout and join steps, in the pair stage, which runs on each workday’s effective punches before they are paired.

[[layer]]
id = "punches"
[[layer.step]]
id = "lockout"
uses = "standard/lockout"
params = { within = "2m" }
[[layer.step]]
id = "join"
uses = "standard/join"
params = { within = "5m" }

A pair step sees ctx.punches (each id, punch, at, kind, punched, device, values, and ignored or close where marked) with ctx.before and ctx.after (the punches either side of the workday’s), and marks them: ctx:ignore(id, why), ctx:direction(id, kind, why), ctx:close(id, at, why). The engine pairs the punches as marked and stamps the segment each mark touches; the punches themselves stay as recorded.

Parameters

StepParameterMeaning
lockoutwithinHow close to the punch before a punch of the same kind (or either of unknown direction) is a duplicate ("2m").
joinwithinHow soon after an out an in joins the work up again ("5m"). Only an out and an in of the same workday.

What the scenarios show

  • a-badge-swiped-twice: a second in a minute after the first and a second out two minutes after the first are ignored, and stamped; a second out three minutes after is not, and has no in.
  • stepping-out-a-moment: back in 3 minutes, one segment; back in 6, two.

This is a common way companies clean up punches; check the rules where you operate. A short break the employer gives may have to be paid, and the time between punches that are joined counts as worked.

Get the recipe

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

double_punch_lockout/package.toml
name = "double_punch_lockout"
version = "1.0.0"
description = "A badge swiped twice within a lockout is one punch, and an out followed by an in within minutes is no break in the work."
# A punch of the same kind within 2 minutes of the one before is a
# duplicate, ignored; an out and an in within 5 minutes of each other
# are joined, the work one stretch.
[[layer]]
id = "punches"
[[layer.step]]
id = "lockout"
uses = "standard/lockout"
params = { within = "2m" }
[[layer.step]]
id = "join"
uses = "standard/join"
params = { within = "5m" }

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 badge swiped twice a minute apart, coming in and going out: the second swipe of each is within the 2-minute lockout, a duplicate, ignored, and stamped on the shift. Without the lockout the second in would leave the first without its out (missing_out) and the second out would have no in (missing_in). Tuesday's out 3 minutes after the first is no duplicate
scenarios/a-badge-swiped-twice.toml
description = "A badge swiped twice a minute apart, coming in and going out: the second swipe of each is within the 2-minute lockout, a duplicate, ignored, and stamped on the shift. Without the lockout the second in would leave the first without its out (missing_out) and the second out would have no in (missing_in). Tuesday's out 3 minutes after the first is no duplicate"
punch = [
{ at = "2026-10-05 08:00", kind = "in" }, { at = "2026-10-05 08:01", kind = "in" },
{ at = "2026-10-05 16:00", kind = "out" }, { at = "2026-10-05 16:02", kind = "out" },
{ at = "2026-10-06 08:00", kind = "in" }, { at = "2026-10-06 16:00", kind = "out" },
{ at = "2026-10-06 16:03", kind = "out" },
]
[policy]
zone = "America/Chicago"
[expect]
week = "2026-10-05"
segments = ["work 2026-10-05 08:00-16:00", "work 2026-10-06 08:00-16:00"]
stamps = [
"2026-10-05 08:00-16:00 work: lockout [[email protected]/punches rev 1]: ignored the punch at 08:01:00: within 2m of the punch before",
"2026-10-05 08:00-16:00 work: lockout [[email protected]/punches rev 1]: ignored the punch at 16:02:00: within 2m of the punch before",
]
exceptions = [{ kind = "missing_in", at = "2026-10-06 16:03" }]
Out at 12:00 and back at 12:03, to move the car: within the 5 minutes the policy joins, the two punches are ignored and the day is one segment. Out at 12:00 and back at 12:06 is a real break in the work: two segments, the 6 minutes unpaid
scenarios/stepping-out-a-moment.toml
description = "Out at 12:00 and back at 12:03, to move the car: within the 5 minutes the policy joins, the two punches are ignored and the day is one segment. Out at 12:00 and back at 12:06 is a real break in the work: two segments, the 6 minutes unpaid"
punch = [
{ at = "2026-10-05 08:00", kind = "in" }, { at = "2026-10-05 12:00", kind = "out" },
{ at = "2026-10-05 12:03", kind = "in" }, { at = "2026-10-05 16:00", kind = "out" },
{ at = "2026-10-06 08:00", kind = "in" }, { at = "2026-10-06 12:00", kind = "out" },
{ at = "2026-10-06 12:06", kind = "in" }, { at = "2026-10-06 16:00", kind = "out" },
]
[policy]
zone = "America/Chicago"
[expect]
week = "2026-10-05"
days = { "2026-10-05" = "8h", "2026-10-06" = "7h 54m" }
segments = [
"work 2026-10-05 08:00-16:00",
"work 2026-10-06 08:00-12:00",
"work 2026-10-06 12:06-16:00",
]