Leap Years, DST, and Other Ways Date Math Goes Wrong

Day counting looks like grade-school arithmetic, yet software ships with date bugs every year and humans miss deadlines over them. These are the five classic failure modes.

1. Leap years

A year is a leap year if it's divisible by 4 — except century years, which must be divisible by 400. So 2024 and 2000 are leap years; 1900 and 2100 are not. Any calculation that assumes "365 days = 1 year" drifts: 365 days from March 1, 2027 is February 29, 2028 — a date that doesn't exist in most years. Contracts that say "one year" should anchor to the anniversary date, not to 365 days.

2. Daylight saving time

When clocks spring forward, one day is 23 hours long. Naive code that computes days as milliseconds ÷ 86,400,000 gets 29.96 days across a March span and rounds down to 29 — a silent off-by-one. The fix (which every calculator on this site uses) is to anchor all dates to noon UTC before subtracting, so no civil-time discontinuity can ever move a result across midnight.

3. Month lengths

"One month later" is ambiguous at month ends: what is January 31 plus one month? Conventions differ — some systems say February 28 (clamp), others March 2 or 3 (overflow). Banking systems typically clamp; JavaScript's Date overflows. If a payment is due "monthly on the 31st", find out which convention applies before the short months arrive.

4. Inclusive vs. exclusive counting

From Monday to Friday is 4 days by subtraction — but 5 days if you count both endpoints, which is how hotel "nights" differ from rental "days", and how prescriptions ("take for 10 days, starting today") differ from deadlines ("within 10 days"). The subtraction convention (start day excluded, end day included) is the default in law and finance; inclusive counting shows up in travel rules like the Schengen 90/180 rule, where both entry and exit days count.

5. Timezones

"Today" is not the same date everywhere — when it's Friday evening in Los Angeles it's already Saturday in Beijing. A deadline of "June 30" means June 30 somewhere; contracts increasingly specify the zone ("23:59 Pacific Time"). Our calculators compute against your device's local date, which is what you almost always want for personal deadlines.

The common thread: date math is fine — it's the conventions that bite. State the convention, then let a calculator do the walking: days from today, business days, or days between dates.