How hours are calculated
Every HourSum page shares one calculation engine. This page documents it in full, with the arithmetic shown line by line so any total can be checked by hand.
The four steps
- Read each clock time as minutes after midnight. 09:00 becomes 540 minutes, 17:30 becomes 1,050 minutes. A 12-hour input such as 5:15 PM is converted to 1,035 minutes.
- Subtract the start from the end. If the end is smaller than the start, add 1,440 minutes (24 hours) and mark the row as an overnight shift.
- Deduct the unpaid break. Break minutes come either from a minutes field or from a break start and end. A break equal to or longer than the shift is reported as an error. A clock-time break must fall entirely within its shift, including when either one crosses midnight.
- Convert for display. Hours and minutes come from integer division by 60; decimal hours come from dividing the worked minutes by 60 and rounding to the chosen precision.
workedMinutes = (endMinutes - startMinutes) - breakMinutes
decimalHours = round(workedMinutes / 60, precision)
hours = floor(workedMinutes / 60)
minutes = workedMinutes % 60 Worked examples
1. A standard day with an unpaid break
09:00 to 17:30 with a 30-minute unpaid break. The span is 1,050 − 540 = 510 minutes, which is 8h 30m. Deducting the break leaves 480 minutes: 8h 00m, or 8.00 decimal hours. A 60-minute lunch instead leaves 450 minutes — 7h 30m and 7.50.
2. An overnight shift
22:00 to 06:00. The end (360 minutes) is smaller than the start (1,320 minutes), so 1,440 is added to the end: 1,800 − 1,320 = 480 minutes. That is 8h 00m and 8.00 decimal hours, with the row marked “+1 day”.
3. Adding rows
1h 45m plus 0h 30m. In minutes that is 105 + 30 = 135, which is 2h 15m and 2.25 decimal hours. Adding the decimal figures row by row would have produced the same answer here, but not when rounded rows are summed, which is why the engine adds minutes first.
4. Converting a duration
45 minutes is 45 ÷ 60 = 0.75 decimal hours. Going the other way, 7.75 decimal hours is 7.75 × 60 = 465 minutes, which is 7h 45m.
5. Adding durations directly
When the durations are already known — 2h 30m plus 1h 45m — the hours and minutes calculator skips the clock times and sums row minutes: 150 + 105 = 255, which is 4h 15m and 4.25 decimal hours. Minutes above 59 carry into hours automatically, so 25h 90m is 1,590 minutes, or 26h 30m. The decimal figure is taken from the exact minute total once, never rounded per row.
6. Rounding to the nearest quarter hour
09:00 to 17:42 is 522 minutes, or 8.70 decimal hours. Rounded to the nearest quarter it becomes 8.75. The minute total stays 522 — only the decimal and any pay estimate based on it change.
What is excluded on purpose
- Overtime premiums — thresholds and rates are set by contract and jurisdiction.
- Tax, social insurance and deductions — a rate produces gross pay only.
- Paid or unpaid status of a break — that is a policy decision, not arithmetic.
- Persisted timesheets — nothing is written to storage, so results must be printed or copied.
- Time zones and daylight saving — both times in a row share one zone.
How the engine is tested
The calculation functions are covered by automated unit tests. The suite includes a standard day with a lunch deduction, an overnight shift, a break entered as a clock window, an overnight break, multiple rows, 12-hour inputs, quarter-hour and one-decimal rounding, and the conversion cases above — plus the invalid inputs that must be rejected rather than guessed at.
Check anything that looks wrong
Questions about the method
Why does HourSum use minutes instead of hours internally?
Clock times are not decimal. Adding 1h 45m and 0h 30m requires carrying 60 minutes into an hour, while adding 105 and 30 minutes does not. Converting once at the start removes that class of error and makes overnight rollover a single addition of 1,440 minutes.
What happens when the end time equals the start time?
It is treated as an error rather than a 24-hour shift. Split a real 24-hour period into two consecutive rows, for example 09:00 to 21:00 and 21:00 to 09:00, so all 24 hours are included without changing the recorded duration.
Does rounding ever change the total minutes?
No. Total minutes are the exact sum of the worked minutes. Only the decimal-hours figure is rounded, and the print summary records which rounding was chosen so the figure can be reproduced.
Are seconds or time zones considered?
Neither. Times are recorded to the minute and both values in a row are assumed to be in the same time zone, which is the normal case for one shift. A shift recorded across a daylight-saving change is therefore calculated as elapsed clock arithmetic, not as elapsed real time.