I built a time card calculator that had one job: work out overtime pay. That sounded simple until I looked at how overtime actually works across the United States. There is no single rule. There are 51 of them.
The federal rule is the easy one. The Fair Labor Standards Act says overtime starts after 40 hours in a workweek, paid at time and a half. Most states just follow that. But a handful of states add their own rules on top, and those are the ones that make a calculator interesting — and easy to get wrong.
California is the big one. Overtime kicks in after 8 hours in a day, not just 40 in a week. Past 12 hours in a day it becomes double time. Work a seventh consecutive day in the same workweek and the first 8 hours are time and a half, then double time after that. Alaska has daily overtime too, after 8 hours a day. Nevada only applies its daily rule if the worker earns below a set threshold. Colorado pays the higher of daily overtime after 12 hours or weekly overtime after 40. Oregon has a daily rule that only applies in mills and factories. Kentucky pays overtime on the seventh consecutive day of work.
My first version had a separate calculator for each state, with the rules baked into each page. That lasted about a week. The moment I found a wrong number — Florida's minimum wage, which had stepped up on 30 September and my table still showed the old figure — I had to fix it in one place and then wonder how many other pages carried the same mistake. That was the point I rebuilt the whole thing around one shared JavaScript file.
The shared file holds a single rules table, keyed by state code. Each state gets one object with the same shape: a daily threshold, a weekly threshold, a double-time threshold, a seventh-day flag, and a short note about the quirk. Most states are just a weekly threshold of 40. California is the longest entry in the table by a long way.
Each state page is now a thin template. It loads the shared file, tells it which state it is, and the calculator does the rest. The page itself holds no logic at all — just the state name, the inputs, and the result area. If a rule changes, I change one line in the rules table and all 51 pages pick it up.
The calculation itself runs in two passes. First it works out daily overtime: for each day, hours above the daily threshold split into time and a half and double time. Then it works out weekly overtime: hours above the weekly threshold across the whole week. The trick is the overlap. In Colorado, for example, a 13-hour day gives one hour of daily overtime, but if the week also passes 40 hours, the same hour must not be counted twice. The code compares the two passes and pays whichever is higher for each hour, never both.
Testing was the slow part. I ran each state through a worked example by hand — California at $16.90 an hour, 32 regular hours plus 8 overtime hours, which should come to $743.60 — and checked the page agreed. I checked every state against the Department of Labor table and then against each state's own labour department page, because the DOL table was the source that got Florida wrong in the first place.
The whole thing runs in the browser. There is no server, no database, no account. The rules table is just a JavaScript object shipped with the page, and the maths happens on the visitor's own device. That keeps it fast and private, and it means the only thing I have to maintain is one file with 51 entries in it.
If you want to see what the finished pages look like, the state overtime calculators are live on mytimecardcal.com. One shared file, 51 rule sets, and a table that finally has Florida right.
