Punches and segments
A punch records three things. One is when someone clocked. Another is what kind of punch it was (in, out, lunch, and so on). The third is anything they picked at the clock, such as a job or work code. Once a punch is recorded it is never changed. Everything that follows is worked out from the punches, taking any corrections into account. That means stretches of work, workdays and hours.
Punches
Section titled “Punches”Every punch has:
- when the person punched;
- what kind of punch it was (below);
- what they picked at the clock, if anything: a job, a work code, a cost center (labor context);
- when it arrived. A clock that was offline sends its punches late. When a punch arrives decides which pay period it lands in if its own period is already closed (period close).
| Kind | Meaning |
|---|---|
| In | Starts work. |
| Out | Ends work. |
| Lunch start, lunch end | Lunch start ends work and starts lunch. Lunch end ends lunch and starts work again. |
| Break start, break end | The same, for a break. |
| Transfer | Still working, but on something else. The work so far ends and new work starts, on the job or code picked with the transfer. |
| Unknown | The clock doesn’t say. The punch switches the person in if they were out, or out if they were working. On lunch or a break, it ends the lunch or break and starts work again. |
Punches are always taken in the order they happened, whatever order they arrived in. Some punches are made at the very same instant, for example when clocks disagree or one is broken. These are taken in the order of their ids, and pair as any others do. A punch’s id is in the person’s facts (GET people/{person}/facts), so the order can be read there.
How punches pair
Section titled “How punches pair”Each punch ends what the person was doing. For most kinds, it also starts what they do next. The table says what each kind does to each state. A segment left open at the end has no end, because the person is still in. It is not an exception.
| Punch | While working | On lunch or a break | Not in |
|---|---|---|---|
| In | missing_out; new work | ends it; work | work |
| Out | ends work | ends it, missing_lunch_end or missing_break_end | missing_in |
| Lunch start, break start | ends work; lunch (break) | ends it, missing_lunch_end or missing_break_end; lunch (break) | missing_in; lunch (break) |
| Lunch end, break end | missing_lunch_start or missing_break_start; still working | ends it; work (missing_break_end if the other kind) | missing_lunch_start or missing_break_start; work |
| Transfer | ends work; work on the new values | ends it; work on the new values | missing_in; work |
| Unknown | ends work | ends it; work | work |
An in, an out and an in at one instant make a segment of no length. It counts no time. It is also an open segment: the person is in, since the last in.
A clock with no lunch keys sends an out and an in for a lunch. That gap is two shifts. The work after it is a start, and a rule on rest between shifts asks its rest. A policy can take an out and an in within a time of each other as a lunch (gap_lunch). Then the break rules count it, and the work around it is one shift. The gap stays unpaid.
The device a punch was made on
Section titled “The device a punch was made on”Every punch names the device it was made on (device, 1 to 256 characters):
- A clock’s punch is made on the clock’s id. A punch with no device, or an empty one, can’t be read.
- A punch recorded through the API names the device of the system that took it. So does a punch that a correction adds. Examples are
mobilefor a phone app andwebfor a web page. A punch that names none, or an empty one, is refused (400).
Each line of work a punch starts shows that punch and its device. Each stretch of work shows the devices of both its punches. Business rules can read the device. The cookbook’s punching only on the devices a person is set up for flags a punch made on a device the person’s employment details do not list. The punch still counts.
Clock records
Section titled “Clock records”A clock record is what the system knows of a device that punches are made on. It is kept under the device’s id. It holds:
- the device’s name;
- the work location it hangs at;
- labels, such as “has no lunch keys” or “second floor”;
- the work values (a site, a cost center) it gives a punch when the person picked none at the clock.
The record holds only how things stand. There is no history to keep. A device with no record is not an error. Examples are a web page, a phone app, and a clock nobody has entered yet. Its punches simply carry nothing from it.
Entering a clock here is separate from setting it up in Connect. Time and Attendance never sets up a clock.
A punch takes the clock as it is when it arrives. The location, labels and values of the clock’s record are stamped on the punch and stay with it. From then on, the rules that decide the person’s time read what the punch carries. They never read the clock’s current record. This means:
- Changing a clock’s record changes the punches that arrive after. It works no one’s time out again.
- A punch made before a clock was entered, or before it was changed, keeps what it had. A payroll person looking at a day sees the clock each punch came from, as it was then.
- The location a clock hangs at is information on the punch. The person’s days, time zone and holidays still follow the person’s own location.
- The values a clock gives are used after the person’s scheduled shift and before the work location (see labor context). They never override what the person picked at the clock.
Business rules can read the stamp. For example, a rule can treat an out and an in close together as a lunch only on clocks that have no lunch keys. It reads that label from the punch.
Re-stamping a clock’s earlier punches
Section titled “Re-stamping a clock’s earlier punches”Changing a clock’s record leaves the punches already stored as they are. If the record was wrong from a known day, re-stamp its punches from that day. For example, the clock was entered with the wrong location, or its lunch keys were switched off long ago.
Give the day in one of two ways:
- As a date. This means the start of that day where the clock hangs, in the zone of its location. A clock with no location needs a time, since a date would be a guess.
- As an exact time.
First look at what it would do. That shows how many of the clock’s punches from then on do not carry the record as it is now, and whose they are. Then do it, saying why.
Nothing is rewritten. Each punch that changes gets a correction beside it. The correction says who asked, when and why. So the stamp the punch arrived with and every stamp since stay on record. The day a payroll person looks at says on the punch that its stamp was re-stamped, by whom and for what reason. The people whose punches changed are worked out again from the first changed day, as for any correction. A clock.restamped event tells other systems, and the audit trail records it. Punches that already carry the record are left alone, so asking again changes nothing.
A very long re-stamp is done in steps of up to 20,000 punches. Each step is a committed change with its own audit entry and event. The command goes on until all are done. Asking again with the same start is always safe.
Corrections
Section titled “Corrections”A punch is never edited. A correction is a separate record that sits beside the punches. It says who made it, when, and why. Each correction does one thing:
| Correction | What it does |
|---|---|
| Add | Adds a punch that should have been there, such as a forgotten out. |
| Move | The punch happened at a different time. |
| Void | The punch shouldn’t count, such as a double punch. |
| Change kind | The punch was a different kind: an in pressed when it should have been an out. |
| Set job or code | Sets or clears the job, work code or other values on the punch. |
Corrections apply in the order they were stored. Some records are at the same instant. The records of one delivery are stamped alike, and two punches can be made at the same instant. These are taken in the order they were stored.
A correction to a punch that doesn’t exist, or one that was already voided, can’t be applied. It is flagged (correction_target_missing) and the others still apply. The flag is an exception about the correction, at the time the correction was recorded. So it shows on that workday.
A set job or code correction names only the values it changes. Each value it names replaces the punch’s own. A value named as an empty string ({"job": ""}) takes the punch’s own away. A value it does not name stays as it was. Of two corrections that set the same value, the one stored last stands.
Because nothing is overwritten, every punch shows both what was punched and what it was taken as. It also shows each correction that changed it.
Example. Someone punched in at 08:00, in again at 08:01, and in at 15:00. A supervisor does four things:
- Voids the 08:01 punch as a double punch.
- Changes the 15:00 punch to an out.
- Moves it to 16:30, because they left at half past four.
- Sets the morning’s job to the packing line.
The day is one stretch of work, 08:00 to 16:30 on packing, eight and a half hours. The job shows that it came from the supervisor’s correction.
Segments
Section titled “Segments”Punches are paired into segments: stretches of work, lunch or break, back to back. Each punch ends what the person was doing. For most kinds, it also starts what they do next. A day of in 08:00, break 10:00 to 10:15, lunch 12:00 to 12:30 and out 16:30 is five segments: work, break, work, lunch, work.
When the punches don’t fit together, the engine pairs what it can. It flags the rest as exceptions instead of guessing:
| What happened | What the engine does |
|---|---|
| An in, then another in with no out between | The first stretch has no end and counts no time. It is flagged as a missing out. The second in starts new work. |
| An out (or a lunch or break start, or a transfer) while not working | Flagged as a missing in. A lunch or break start still starts the lunch or break. A transfer still starts work. |
| A lunch or break end while working, or while not working | Flagged as a missing lunch or break start. If they weren’t working, work starts there. |
| An out, or a new lunch or break, while still on lunch or a break | The lunch or break ends there. It is flagged as a missing lunch or break end. |
| Someone is still in at the end | Not a problem. Their time counts once the out arrives. |
The job follows the shift. Work takes the job or code picked with the punch that started it, until a transfer changes it. Lunches and breaks keep the job of the work around them. An in after an out starts fresh. The job of the earlier work isn’t carried into it.
Example. In at 08:00 on packing, transfer at 10:30 to the forklift, lunch 12:00 to 12:30, out at 16:30:
| Segment | Time | Job |
|---|---|---|
| Work | 08:00 to 10:30 | packing |
| Work | 10:30 to 12:00 | forklift |
| Lunch | 12:00 to 12:30 | forklift |
| Work | 12:30 to 16:30 | forklift |
Only work counts as time worked. Whether a lunch or break is paid is set by the pay categories (pay categories).
Shifting a clock’s punches
Section titled “Shifting a clock’s punches”Sometimes a clock’s time was wrong for a stretch, so it sent its punches at the wrong time. A clock that kept standard time through daylight saving is an hour behind. Connect tells it, as a clock behind. Each of its punches has a clock_behind exception.
Set the clock right first. Then shift its punches for the stretch it was wrong. That way you do not correct hundreds of punches one by one:
hourctl attend clocks shift Z34ACMEN00118 --from 2026-03-09 --to 2026-03-14 \ --by-seconds 3600 --preview--from and --to are dates or times. A date means the start of that day in the zone of the clock’s location. A clock with no location needs times. The range is of the punches’ times as the clock reported them, --to not included. The preview says how many punches would move and whose they are. Run it without --preview and say why (--reason).
Nothing is rewritten. Each punch in the range gets a correction that moves it. The correction says who asked, when and why. So the punch as it came and every move stay on record. The day shows the punch where it now stands, with the one it came as. The people whose punches moved are worked out again from the first changed day, as for any correction. A clock.shifted event tells other systems, and the audit trail records it.
A punch a correction has moved already (or voided) is left alone. So a supervisor’s own fix is never moved twice. Asking again with the same request name changes nothing it did. The request name is --request-id. hourctl makes one up and says it when you leave it out.
A very long shift is done in steps of up to 20,000 punches. Each step is a committed change with its own audit entry and event. The command goes on until all are done.
To take a shift back, give --undo with the request name of the shift. Each punch it moved goes back to the time it was made, unless another correction moved it since. A shift that was wrong is so a pair of requests, both on record.
When punches are messy
Section titled “When punches are messy”Real clocks produce messy punches. Your policy can tidy them before they’re paired, without changing what was recorded:
- Double punches. A badge swiped twice within a couple of minutes: the second is ignored.
- Clocks with no in or out keys. Each punch is given a direction. The first after a long gap is an in, or whichever end of the scheduled shift it’s nearer to.
- A forgotten clock-out. A shift longer than, say, 16 hours is flagged (
shift_too_long). Or it is ended automatically at that limit, so the next punch starts fresh. - Stepping out for a moment. An out and an in a few minutes apart are joined, and the work runs on as one stretch.
Every punch stays on record as it came, and the timecard notes what the rule did. See the cookbook for each.
A punch from a clock that was behind
Section titled “A punch from a clock that was behind”When the device engine tells that a clock is behind (a clock behind), the punches it sends carry how far (clock_behind_seconds). Time and Attendance keeps that on the punch. It also keeps the punch’s time as the clock reported it. It never changes a time by itself.
The person has a clock_behind exception about each such punch, at its time. So a supervisor sees what to check. The day lists the punch with the number. Correct it as any punch. A correction moves it to the time it was made (the exception goes with it), or voids it.
Workdays
Section titled “Workdays”Each segment belongs to the workday it starts on, and so to that workday’s week and pay period. A night shift from Sunday 22:00 to Monday 06:00 belongs to Sunday, and to last week, unless your policy says otherwise (below).
Workdays are counted in the person’s time zone. They start at the time a policy sets as the start of the day (midnight unless a policy says otherwise). With the day starting at 04:00, anything before 04:00 belongs to the day before. That also keeps a night shift with a lunch after midnight on one workday. The work after a 02:00 lunch still belongs to the night it started.
Time is counted as it actually passed. On the night the clocks go back for daylight saving time, 22:00 to 06:00 is nine hours. Every moment belongs to exactly one workday, even in the hour the clocks repeat or skip.
Overnight shifts. Laws differ on which day a shift that runs past the day’s start belongs to. Weekly overtime counts hours in the week they’re worked. Some daily overtime laws count each fixed 24-hour workday on its own. So a shift from 20:00 to 06:00 is four hours on one day and six on the next. Your policy chooses, with the attribute rule:
| Choice | A shift from Monday 20:00 to Tuesday 06:00 |
|---|---|
| Whole, to the day it starts (the default) | 10 hours on Monday |
| Whole, to the day it ends | 10 hours on Tuesday |
| Split at the day’s start | 4 hours on Monday, 6 on Tuesday |
A split shift’s two pieces are counted, rounded, approved and exported, each on its own day. The split isn’t a punch, so rounding never moves it. The pieces always add up to the shift.
Moving time zones. A person’s time zone can change from a given day, when they move or transfer. Their earlier time stays counted in the zone they were in then. Nothing in the past is reinterpreted.
Exceptions from punches
Section titled “Exceptions from punches”| Exception | When |
|---|---|
missing_out | An in with no out before the next in. |
missing_in | An out, lunch or break start, or transfer while not working. |
missing_lunch_start, missing_break_start | A lunch or break end with no start. |
missing_lunch_end, missing_break_end | An out, or another start, while still on lunch or a break. |
correction_target_missing | A correction to a punch that doesn’t exist, or was voided. It is about the correction, at the time the correction was recorded. |
Exceptions clear themselves. Correct the punches and the exception goes away. One that is fine as it is can be excused instead. See exceptions for every one.