Skip to content

Main content

Civil Day Fraction Midnight Policy

Convert explicit non-leap-second civil clock fields to a day fraction with an explicit 24:00 end-of-day policy.

Loading tool…

Description

Convert a supplied clock to a fixed 24-hour day fraction with an end-of-day policy.

Date formats distinguish calendar years from ISO week-years, known day precision from unknown-day masks, and midnight at the start versus end of a day. A fixed 86400-second day fraction does not encode civil timezone transitions. Partial-date wording preserves uncertainty rather than silently choosing a date.

Convert a supplied clock to a fixed 24-hour day fraction with an end-of-day policy.

When to use this tool

Use Civil Day Fraction Midnight Policy when you already have hour, minute, second, allowEndOfDay and need to convert a supplied clock to a fixed 24-hour day fraction with an end-of-day policy.

How to use the tool and how it works

  1. Enter hour, minute, second, allowEndOfDay. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read dayFraction, nextDayMidnight. Inspect nextDayMidnight before interpreting the associated values.

Require whole hour 0..24, minute 0..59 and seconds in [0,60); hour 24 requires allowEndOfDay=true, minute=0 and second=0. Divide total seconds by 86400 and flag hour 24 as nextDayMidnight.1

Input fieldMeaning and unitsAccepted input
hourHourRequired. Safe integer; minimum 0; maximum 24.
minuteMinuteRequired. Safe integer; minimum 0; maximum 59.
secondFinite second in [0,60), allowing fractions but excluding leap-second 60.Required. Finite number; minimum 0; strictly below 60.
allowEndOfDayAllow End Of DayRequired. Boolean.
Output fieldInterpretationReturned shape
dayFractionDay FractionRequired. Finite number.
nextDayMidnightTrue only for permitted 24:00:00; dayFraction=1 without choosing a next calendar date.Required. Boolean.
json
{
  "input": {
    "hour": 12,
    "minute": 0,
    "second": 0,
    "allowEndOfDay": false
  },
  "output": {
    "dayFraction": 0.5,
    "nextDayMidnight": false
  }
}

Limitations and assumptions

  • Fractional seconds are accepted, leap-second 60 rejected. A fraction of one denotes the next midnight without updating a date; real civil-day lengths and daylight-saving changes are not modeled.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
  • Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.

Alternative or Complementary methods

Use a complete calendar/timezone conversion when relating week dates, timestamps or local schedules. Preserve unknown precision explicitly and choose an endpoint policy before calculation; a formatter or fixed-day fraction does not resolve missing dates or civil-time rules.

References

  1. Calculation and input contract: date/civil-day-fraction-midnight-policy — tool.io

Similar or alternative tools