Most clock-time subtraction feels obvious until the end time looks smaller than the start time. That is the signature of an interval that runs past midnight, and the clock duration calculator has a dedicated branch for it.
When an end clock time is numerically earlier than the start time, the interval has crossed midnight. The clock duration calculator handles it with a wrap-around branch: take the absolute difference between the two times and subtract it from 86,400, the number of seconds in a full day. In 12-hour mode, pm times first receive a 43,200-second offset, so the same rule applies to am/pm entries.
What does the 86,400-second wrap-around do?
Both the 12-hour and the 24-hour duration outputs use the same conditional form. Subtract the start time from the end time; when that result is negative, the calculator replaces it with 86,400 minus the absolute value of the difference. In effect it adds the time from the start reading to midnight to the time from midnight to the end reading.
| Constant | Value | Where it comes from |
|---|---|---|
| Seconds in a full day | 86,400 | the wrap-around term in both duration equations |
| pm offset | 43,200 s | the AM/PM dataset value for pm |
| am offset | 0 s | the AM/PM dataset value for am |
| Clock format codes | 0 = 12-hour, 1 = 24-hour | the clock format dataset |
Worked example: reversing the 7:48 am to 4:13 pm interval
The calculator's own example gives 8 hours 25 minutes from 7:48 am to 4:13 pm. Read those two clock times in the opposite order and the subtraction becomes negative, so the wrap-around branch applies.
The absolute difference between the two readings is still the 8 hours 25 minutes from the forward example. Subtracting it from a full day of 86,400 seconds leaves 15 hours 35 minutes — the interval from the later reading to the earlier one on the following day. No new clock arithmetic is required; the branch simply completes the day around the two known readings.
Frequently Asked Questions
Why is the wrap-around 86,400 and not 43,200?
Because 43,200 seconds is the half-day pm offset used to place afternoon times on a 24-hour scale, while a full day is 86,400 seconds. An interval that runs past midnight must be completed across the whole day, so the full-day value is the correct one to subtract from.
Does the 24-hour format avoid the wrap-around?
No. The 12-hour and 24-hour duration equations contain the same conditional branch. The format changes only how you enter the times; it does not change what happens when the end reading is earlier.
What if the two clock times are equal?
The subtraction gives zero rather than a negative number, so the ordinary branch applies and the clock duration is zero.
References
- Omni Calculator, Clock Duration Calculator: duration equations and the 86,400-second wrap-around constant.
- Clock Duration Calculator AM/PM dataset: 0 seconds for am and 43,200 seconds for pm.
- The calculator's 7:48 am to 4:13 pm example, used here in reverse.