How Date Calculators Handle Months, Years, and Leap Days
Adding one month is not adding 30 days. Adding one year is not adding 365 days when a leap day is involved. The months and years calculator applies signed years, then signed months, then signed days, and clamps overflowing day-of-month values to the last valid day of the landing month. The examples below are the same rules as the code.
Why one month is not 30 days
January 1 plus 30 calendar days is January 31. January 1 plus one calendar month is February 1. Those results differ by a day already, and the gap changes in other months. March 1 plus 30 days is March 31; March 1 plus one month is April 1. If a plan says “same day next month,” use month arithmetic. If it says “in 30 days,” use the add days tool.
Months with 28, 29, 30, and 31 days
April, June, September, and November have 30 days. February has 28 or 29. The rest have 31. Any method that stores a date as year + month + day must decide what happens when the day does not exist in the landing month. Datefold Studio clamps. It does not roll into the next month the way a naive JavaScript Date overflow would (January 31 plus one month becoming March 2 or 3 depending on leap year).
Leap-year rules
A year leaps when it is divisible by 4, except years divisible by 100, unless also divisible by 400. 2000 leaps. 1900 does not. 2024 leaps. 2025 does not. 2100 does not. February 29 exists only in leap years. The weekday finder will reject February 29, 2025 as not a real date if it is typed; native controls usually hide that day.
End-of-month clamping
Worked example 1: January 31, 2025 + 1 month. After the month step the target is February 2025, which has 28 days, so the day clamps from 31 to 28. Result: February 28, 2025. The result panel explains that a clamp occurred.
Worked example 2: January 31, 2024 + 1 month. February 2024 has 29 days, so the clamp lands on February 29, 2024. The extra leap day is used rather than falling back to the 28th.
February 29
February 29, 2024 + 1 year: years are applied first. 2025 is not a leap year, so February 29 is invalid and clamps to February 28, 2025. If you then added days, those days would start from February 28, not from a fictional 29th. That is why order matters.
Adding years
March 15, 2020 plus 5 years is March 15, 2025. No clamp. February 29 plus a year into a common year always clamps. Negative years move backward with the same rule: February 29, 2024 minus 1 year is February 28, 2023.
Combining years, months, and days
Suppose January 31, 2024, years = 1, months = 1, days = 1. Order: years first → January 31, 2025 (no February involved yet). Months next → February 28, 2025 (clamp). Days last → March 1, 2025. If the code added months first instead, January 31, 2024 + 1 month would be February 29, 2024, then +1 year would clamp to February 28, 2025, then +1 day would be March 1, 2025—the same landing in this particular mix, but not in every mix. Try years = 1, months = 0, days = 0 on February 29, 2024 versus months = 12 on the same date: years-first clamp happens at the year step; twelve months is a month-step equivalent that also lands on February 28, 2025. Other combinations diverge. Always read the sequence line the tool prints.
Why adjustment order matters
Days applied before months would move January 31 to February 1 (plus one day) and then add a month to March 1, skipping the January 31 clamp entirely. Datefold Studio documents years → months → days so a repeat visit gets the same policy. Out-of-range landings (before 1900 or after 2100) show an error.
Related: adding days and days between dates.
Questions
Does the tool use JavaScript month overflow?
No. It computes the target year and month, then clamps the day to that month’s length.
What if I only want extra days, not a month?
Leave months and years at 0 and set days, or use the add-days calculator.
Will I be told when a clamp happens?
Yes. The note names the step (year or month) and the clamped intermediate date.