Almost everyone can recite the rule: a leap year comes every four years, adding a 29th day to February. It is one of the first pieces of calendar trivia we learn. And it is wrong — or at least, incomplete in a way that matters. The year 2100, despite being divisible by four, will not be a leap year. Understanding why reveals one of the most quietly brilliant pieces of engineering in everyday life.

The leap year exists to solve a genuine astronomical problem: the Earth does not orbit the Sun in a whole number of days. This guide explains the mismatch, the three-part rule that corrects it, why the exceptions exist, and the surprising places the rule still catches software and people out.

The problem leap years solve

A year — one full orbit of the Earth around the Sun — takes not 365 days but about 365.2422 days. That extra quarter-day or so is small, but it does not go away. Ignore it, and the calendar drifts against the seasons by roughly a day every four years.

Left uncorrected, the drift compounds relentlessly. After a century the calendar would be off by around 24 days; after a few centuries, festivals fixed to the calendar would slide into entirely the wrong season — midsummer celebrations creeping toward autumn. Leap years exist to soak up that fractional remainder and keep the calendar locked to the Earth's journey around the Sun.

The real rule has three parts

The Gregorian calendar's leap-year rule is not "every four years" but a three-step test, applied in order:

  1. Divisible by 4? If not, it is a common year. This catches the ordinary case.
  2. Divisible by 100? If a year passes the first test but is also divisible by 100, it is *not* a leap year — an exception.
  3. Divisible by 400? If it fails at step two but is divisible by 400, it *is* a leap year after all — an exception to the exception.

So 2024 is a leap year (divisible by 4, not by 100). 1900 was not (divisible by 100, not by 400). 2000 was (divisible by 400). And 2100 will not be — it is divisible by 100 but not by 400. This nested rule is why software uses a proper calendar library rather than a naive "year % 4" check, and it underlies how the day of the year shifts.

Why the exceptions exist

The "every four years" rule slightly over-corrects. Adding a full day every four years assumes the extra fraction is exactly 0.25 of a day, but it is closer to 0.2422. That tiny difference means the simple rule adds a bit too much time — about three days too many every four centuries.

How each layer of the rule fine-tunes the calendar.
RuleLeap days addedEffect
Every 4 years1 per 4 yearsOver-corrects slightly
Except every 100removes 3 per 400 yearsPulls it back
Except every 400adds 1 back per 400 yearsFine-tunes the balance

The net result: 97 leap years in every 400, not 100. That gives an average calendar year of 365.2425 days — astonishingly close to the true 365.2422. The leftover error is so small that it will take thousands of years to add up to a single day.

A brief history

The older Julian calendar, introduced under Julius Caesar, used the simple "every four years" rule. Over centuries its small over-correction accumulated, and by the sixteenth century the calendar had drifted about ten days out of step with the seasons, throwing off the date of Easter.

The fix, introduced in 1582, was the Gregorian calendar with its refined century rule — and a one-time skip of ten days to realign things. The full, fascinating story of that transition, and why different countries adopted it decades or centuries apart, is told in our history of the Gregorian calendar.

Where leap years still catch people out

For something so well understood, the leap year causes a surprising amount of trouble:

  • Software bugs. Naive "year % 4" checks get century years wrong; other code forgets 29 February exists entirely and crashes on that date.
  • Leaplings. People born on 29 February have a "real" birthday only once every four years and must pick 28 February or 1 March in between.
  • Annual calculations. Interest, subscriptions, and age reckoning that assume 365 days need to handle the 366-day year.
  • Day-of-year conversions. After 28 February, every date's day-number shifts by one in a leap year.

The upside and the awkwardness

The upside

  • Keeps the calendar aligned with the seasons for millennia
  • The rule is deterministic and easy for software to apply correctly
  • Average year of 365.2425 days is extraordinarily close to the true value
  • Requires no ongoing manual intervention, unlike leap seconds

The catch

  • The century exceptions trip up naive calculations
  • 29 February creates edge cases for birthdays, contracts, and code
  • A 366-day year breaks assumptions baked into "365-day" logic
  • The rule is more complex than the "every four years" most people remember
The leap year is a 2,000-year-old patch for a rounding error in the heavens — and it is still holding.

What about leap seconds?

Leap years handle the mismatch between the calendar and the Earth's orbit. A separate, unrelated adjustment — the leap second — occasionally handles the mismatch between our clocks and the Earth's slightly irregular rotation. The two are often confused but solve entirely different problems: leap years keep dates aligned with the seasons, leap seconds keep time-of-day aligned with the planet's spin. Unlike leap years, leap seconds follow no fixed rule and are announced only a few months ahead.

The seasons the calendar actually tracks

It is worth being precise about *which* year the leap rule keeps in step. The 365.2422-day figure is the tropical year — the time from one spring equinox to the next — not the slightly longer time the Earth takes to return to the same point relative to the distant stars. The Gregorian calendar deliberately tracks the tropical year, because that is what governs the seasons, and keeping the equinoxes fixed is what stops festivals like Easter from slowly drifting.

This is also why the older Julian calendar eventually failed. Its 365.25-day year was tuned a touch too long, so the equinox crept earlier by about three days every four centuries. The Gregorian century rule shaved off exactly that excess, and the result has held the equinox to within a day or so for more than four hundred years — a remarkable feat of calendar engineering from 1582.

Key takeaways
  • A year is about 365.2422 days, so the calendar needs leap days to avoid drifting from the seasons.
  • The rule is: divisible by 4, except century years, which must be divisible by 400.
  • That gives 97 leap years per 400 years and an average year of 365.2425 days.
  • 2000 was a leap year; 1900 and 2100 are not — the century exception in action.
  • Naive "divisible by 4" checks are a classic software bug that fails on century years.