Convert each duration to seconds
Apply total seconds = hours × 3,600 + minutes × 60 + seconds. The input 1:45:30 becomes 1 × 3,600 + 45 × 60 + 30 = 6,330 seconds. The parser requires two digits for minutes and seconds and keeps both between 00 and 59. Duration hours may be larger than 24, but are capped at 1,000,000 to keep inputs and output within a deliberate range.
Perform one integer operation
Add or subtract the two integer totals. For 1:45:30 plus 0:35:45, the second value is 2,145 seconds and the combined value is 8,475 seconds. Subtraction uses the same process. If the second duration is larger, the result remains negative; the minus sign belongs to the whole duration rather than only to the hours column.
Normalize back to clock units
Take the absolute result, divide by 3,600 to obtain whole hours, then divide the remainder by 60 for whole minutes. The final remainder is seconds. Restore a negative sign only after normalization. For 8,475 seconds this yields two hours with 1,275 seconds left, then 21 minutes with 15 seconds left: 02:21:15.
Keep days visible when useful
Do not wrap duration hours at 24. A 27-hour task is 27:00:00, not 03:00:00, because 03:00 is only the residual clock reading after one day. Reporting both the unbounded form and a human form such as 1 day, 3 hours preserves the total. Decimal hours are another representation: divide total seconds by 3,600 and keep enough precision for the use case.
Separate durations from clock readings
The input 30:00:00 is valid as a duration but invalid as a time on a 24-hour clock. Likewise, adding two clock readings rarely answers a meaningful elapsed-time question. Use duration mode for shifts, recordings, training intervals, or accumulated tasks. Use clock mode only when the first value is a start reading and the second is an end reading on the same or immediately following day.
Audit and troubleshoot the result
If the answer looks one hour or one minute off, inspect the displayed seconds equation before changing the inputs. Verify that 1:30 means one hour and thirty minutes only when entered as 1:30:00; 1:30:30 includes thirty seconds. Check whether subtraction order is correct and whether a negative sign is expected. For payroll or regulated records, also apply the required rounding and break policies outside this arithmetic aid.