Skip to content

Main content

Calendar Month End Subtraction Clamp Loss Tool

Compute calendar month end subtraction clamp loss from explicit bounded inputs.

Loading tool…

Description

Clamp a source day to a supplied target-month length.

Civil calendar arithmetic needs explicit year numbering, leap rules and index origins. A weekday mask or Gregorian component operation does not identify a timezone, working calendar or historical calendar reform.

Clamp a source day to a supplied target-month length.

When to use this tool

Use Calendar Month End Subtraction Clamp Loss when checking the stated weekday or Gregorian calendar convention.

How to use the tool and how it works

  1. Enter sourceDay, targetMonthDays. 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 targetDay, lostDays. Use the output convention below.

Clamp a source day to a supplied target-month length. Require sourceDay 1-31 and targetMonthDays 28-31; targetDay is their minimum and lostDays is the nonnegative difference.1

Input fieldMeaning and unitsAccepted input
sourceDaySource DayRequired. Safe integer; minimum 1; maximum 31.
targetMonthDaysTarget Month DaysRequired. Safe integer; minimum 28; maximum 31.
Output fieldInterpretationReturned shape
targetDayTarget DayRequired. Safe integer.
lostDaysLost DaysRequired. Safe integer.
json
{
  "input": {
    "sourceDay": 31,
    "targetMonthDays": 28
  },
  "output": {
    "targetDay": 28,
    "lostDays": 3
  }
}

Limitations and assumptions

  • No actual month subtraction, target year or calendar arithmetic is performed.
  • 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 an appropriate full calendar library and authoritative local rules when business days, historical dates or real scheduling matter.

References

  1. Calculation and input contract: date/calendar-month-end-subtraction-clamp-loss — tool.io

Similar or alternative tools