When I built the first version of my time card calculator, each day had one break field. One lunch break, one start, one end, one total. It seemed like enough. Nobody works a shift with more than one break, right?

Wrong. Within a week of the site going live, people were doing something I had never planned for: typing two breaks into a single field. "30+15" in the lunch box. "20, 20" in the minutes field. A few even left a note in the name field: "took a second break". The calculator just ignored all of it, or worse, parsed the first number and silently dropped the rest. Their totals were wrong and they knew it before I did.

Why one break was never enough

Real shifts are messy. A warehouse worker gets a 30-minute unpaid lunch and a 15-minute paid break. A nurse takes a meal break at noon and another short break at four. A retail worker on a ten-hour shift gets two paid 15-minute breaks plus lunch. None of this is exotic — it is just a normal working day, and my single break field was pretending otherwise.

The mistake was thinking of a break as a property of the day. It is not. A break is a thing in itself: a start, an end, and whether it is paid. Once I thought of it that way, the fix became obvious. Each day should hold a list of breaks, not a single break.

The rebuild

The change touched three places. First, the data model. Instead of breaks: 30 per day, each day now stores an array:

breaks: [ { start: "12:00", end: "12:30", paid: false }, { start: "15:00", end: "15:15", paid: true } ] 

Paid breaks count towards hours worked; unpaid ones are subtracted. That one boolean is the whole difference between a correct total and a short pay cheque, so it sits right next to the times in the form, not buried in settings.

Second, the form. Each day now has an "Add break" button that appends a new row. The first row is still lunch, because that is what most people use. The second row appears only when someone asks for it, so the form stays simple for everyone else. Each row can be removed with a small cross, and removing the last one is blocked — a day with no break at all is fine, but a day with a broken half-row is not.

Third, the maths. The paid-hours calculation loops over the break array instead of reading a single value, which is actually simpler code than the special-casing I had before. The old version had a tangle of if (breakMinutes) checks; the new one is a plain loop and a sum. It also made the total easier to test: one break, two breaks, three breaks, a paid one in the middle, an unpaid one at the edge. Every combination passed on the first run, which is more than I can say for the original.

What I learned

The lesson is not really about breaks. It is that a form field should match the shape of the thing it collects. A shift is a list of work periods with gaps between them, and a single break field forced a list into a single number. Users did not complain — they just bent their data to fit the form and got wrong answers. That is the worst kind of bug: silent, and blamed on the user, not the tool.

So now the calculator lets a day have as many breaks as it needs. Most people still use one. A few use two. One person, somewhere, used three, and their total was right. That is the whole point.

You can try it on mytimecardcal.com — add a second break to any day and watch the total change.