Clock Time Difference Calculation Methodology (Sexagesimal & Modular Math)
Computing the exact interval between two clock times requires standardizing 12-hour AM/PM values into a continuous 24-hour timeline, resolving sexagesimal borrowings, and applying modular math for midnight rollovers.
To find the difference between two clock times, convert both to 24-hour military format and subtract start from end. If the end time is on the next day, add 24 hours (1,440 minutes) to the end time before subtracting.
Elapsed Seconds = (End 24h Seconds + (End < Start ? 86,400 : 0)) - Start 24h Seconds
24-Hour Timeline Normalization
Convert both clock inputs from 12-hour AM/PM notation into 24-hour format. AM hours stay identical (with 12:00 AM becoming 00:00), while PM hours add 12 (with 12:00 PM remaining 12:00).
Sexagesimal Second & Minute Resolution
Convert hours, minutes, and seconds into total cumulative seconds from 00:00:00 midnight using the formula: Total Seconds = (Hours × 3,600) + (Minutes × 60) + Seconds.
Cross-Midnight Boundary Check (Modular Addition)
If the end timestamp is numerically smaller than the start timestamp, the event crosses midnight. Add 86,400 seconds (or 1,440 minutes) to the end timestamp to maintain continuous forward progression.
Interval Subtraction & Base-60 Decomposition
Subtract start seconds from adjusted end seconds. Decompose the net difference back into whole hours (⌊seconds ÷ 3,600⌋), remaining minutes (⌊remainder ÷ 60⌋), and remaining seconds.
Calculation Edge Cases & Assumptions
Condition: End time is smaller than start time (e.g., 10:30 PM to 06:15 AM)
Rule: Add 24 hours (1,440 minutes or 86,400 seconds) to the end timestamp to avoid negative durations.
Condition: Start time and end time match exactly
Rule: Indicates 0 seconds for instant point-in-time checks, or 24 hours for complete single-day duty cycles.
Condition: End minutes or seconds are smaller than start minutes or seconds
Rule: Borrow 60 seconds from minutes or 60 minutes from hours before subtracting individual time columns.