01Time Duration
Time Duration
Wall-clock model
TimeDateLab compares the displayed local clock and calendar values. It does not perform timezone conversion and does not calculate real zoned elapsed time across DST transitions. Every duration fact is derived from total seconds.
- Model
- Wall-clock time
- Timezone
- Not applied
- DST
- Not applied
- Truth source
- Total seconds
Time-only calculation
Calculation rule
Total seconds= end seconds− start seconds+ next-day offset × 86,400
The next-day offset is either 0 days or 1 day. Same-day calculations add no day; Ends next day adds exactly 86,400 seconds.
Time-only edge cases
- 09:00 → 09:00
- Result: 0 hours
- 09:00 → next day 09:00
- Result: 24 hours
- 23:59:59 → next day 00:00:00
- Result: 1 second
- 11:30 PM → next day 1:15 AM
- Result: 1 hour 45 minutes
If the end is earlier than the start and next-day semantics are disabled, the calculator returns a recoverable error instead of a negative duration.
Date & time calculation
Calculation model
Date-time scalar= civil day index × 86,400+ seconds of dayDuration= end scalar − start scalar
Dates make the day boundary explicit, so Ends next day is not used in this mode. A reversed date-time returns an error. Timezone and DST elapsed-time semantics still do not apply.
Precision and rounding
- The default visible and calculation precision is minute precision.
- Include seconds enables second precision. Disabling it resets hidden start and end seconds to zero.
- The exact duration remains based on total seconds. Decimal hours and decimal minutes are derived from it.
- Decimal values use two-place half-up rounding. The ≈ marker appears only when the displayed decimal is not exact.
Limits
- Supported clock range: 00:00:00–23:59:59.
- Leap seconds are not included.
- No timezone conversion or DST elapsed-time adjustment is applied.
02Work Hours
Work Hours
Single-shift model
Work Hours Calculator uses the same timezone-free Wall-clock Duration as Time-only Calculation. It accepts one start time, one end time, an explicit 0-or-1 next-day offset, and one whole-minute break deduction.
Calculation rule
Gross seconds= end seconds − start seconds+ next-day offset × 86,400Net work seconds= gross seconds − break minutes × 60
- Break minutes must be a non-negative whole number and cannot exceed the gross shift.
- Net work time, decimal hours, and total minutes are all derived from the same net-second fact.
- Decimal hours use the same two-place half-up rule as Time Duration.
- Weekly cards, multiple shifts, pay, overtime, tax, holidays, timezones, and DST are outside this model.
03Day Counter
Day Counter
Civil-date model
Civil dates use the proleptic Gregorian calendar from through . The modern Gregorian leap-year rule is projected backward before 1582. Each validated date becomes an integer civil day index for subtraction.
- Calendar
- Proleptic Gregorian
- Range
- –
- Date value
- Civil day index
Leap-year rule
A year is a leap year when it is divisible by 4, except when divisible by 100, unless it is also divisible by 400.
- 1900
- Not a leap year
- 2000
- Leap year
- 2100
- Not a leap year
Endpoint rule
Default
[start, end)
Start date included · End date excluded
Include end date on
[start, end]
Start date included · End date included
- Same date
- Off: 0 days · On: 1 day
- Adjacent dates
- Off: 1 day · On: 2 days
Weekday and weekend breakdown
Monday–Friday are weekdays. Saturday–Sunday are weekend days. Public holidays are not subtracted, so this is not a holiday-aware business-days calendar.
Every complete 7-day span contributes 5 weekdays and 2 weekend days. Any remaining dates are classified individually.
Calculation invariant
Weekdays + weekend days = calendar days
Edge cases and limits
- The same endpoint and calendar rules continue across month and year boundaries, including the 1900 and 2000 leap-year cases.
- When the end date is earlier, the calculator reports an error. It does not silently swap the dates or return an absolute value.
- There is no public-holiday calendar, custom workweek, or date add/subtract function.
05Verification
Verification
Implementation confidence comes from several complementary kinds of checks.
- Boundaries
- Fixed examples cover leap-year boundaries, same-time and overnight cases, supported date-range edges, and reversed inputs.
- Invariants
- Generated inputs check relationships such as weekday and weekend conservation, stable share round trips, and safe invalid-state handling.
- Independent comparison
- During development, civil-date calculations are compared with an independent calendar implementation. The comparison library is development-only and is not shipped in production.
- Browser and interface
- Real-browser checks cover English and Chinese calculator flows, keyboard and accessibility behavior, mobile and zoom layouts, sharing, copying, error recovery, and network/privacy boundaries.
These checks improve confidence, but they do not prove that defects are impossible, provide certification, or constitute formal verification.