Skip to content
Calendar

How Leap Years Work: The 4, 100, and 400 Rule

A year lasts about 365.2422 days, so the calendar needs a correction. The leap-year rule is a three-line algorithm that keeps the seasons in place.

The Earth takes about 365.2422 days to go once around the Sun as measured by the seasons (the tropical year, roughly one spring equinox to the next). A calendar can only contain whole days. Every calendar is therefore an approximation, and the leap year is the correction that keeps the approximation from drifting.

Without it, a 365-day calendar would slip against the seasons by nearly a quarter of a day each year — about 24 days per century. Within about 750 years, July would be a winter month in the Northern Hemisphere.

The rule

The Gregorian calendar, which almost every country uses for civil purposes, decides leap years with three tests:

  1. If the year is divisible by 4, it is a leap year…
  2. …unless it is divisible by 100, in which case it is not…
  3. …unless it is also divisible by 400, in which case it is.

In code:

leap = (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0)

Some examples:

Year÷ 4÷ 100÷ 400Leap year?
2024yesnonoYes
2026nononoNo
2028yesnonoYes
1900yesyesnoNo
2000yesyesyesYes
2100yesyesnoNo

A leap year has 366 days. The extra day is 29 February.

Why the rule has three parts

Each step is a finer correction to the one before it.

  • Every 4 years gives an average year of 365.25 days. That is slightly too long — by about 11 minutes a year.
  • Skipping century years removes three leap days every 400 years, pulling the average down.
  • Keeping every fourth century puts one of them back.

The result is 97 leap years in every 400-year cycle, for an average year of 365.2425 days. Compared with the real figure of roughly 365.2422, the calendar gains about 26 seconds a year — one full day in a little over 3,000 years. Nobody has yet needed to decide what to do about that.

Where it came from

The Julian calendar

The Roman republic’s calendar had drifted badly by the first century BC, partly because extra months were inserted by officials for political convenience. Julius Caesar replaced it with a simple solar calendar that took effect in 45 BC: 365 days, with one extra day every fourth year.

That is the first rule on its own. It was a huge improvement, but the 11-minute annual error accumulated at about one day every 128 years.

The Gregorian reform

By the sixteenth century the spring equinox had moved from around 21 March to around 11 March. This mattered to the church because the date of Easter is calculated from the equinox.

In 1582 Pope Gregory XIII issued a reform with two parts:

  • A one-time jump. Ten days were removed to bring the equinox back. Thursday 4 October 1582 was followed directly by Friday 15 October 1582.
  • A new leap rule. The century exception was added so the drift would not return.

Catholic countries such as Spain, Portugal, and the Italian states switched immediately. Others took much longer, and by then had more days to drop:

CountryYear of adoptionDays skipped
Spain, Portugal, Italian states158210
Great Britain and its colonies175211
Russia191813
Greece192313

For 170 years, a letter sent between London and Paris could carry two different dates depending on which side wrote it. Historians still mark dates from the period as “Old Style” or “New Style” to avoid confusion.

Why February?

In the early Roman calendar the year began in March, which made February the last month — the natural place to put any adjustment. That is also why September, October, November, and December carry names meaning seventh, eighth, ninth, and tenth, even though they are now months nine to twelve. When the start of the year moved to January, the leap day stayed where it was.

Practical consequences

Birthdays on 29 February. Someone born on a leap day has a true anniversary only once every four years. In common years, most people celebrate on 28 February or 1 March, and the legal date on which they reach a given age depends on the country.

Weekdays shift by two. A given date normally moves forward one weekday each year, because 365 is one more than a multiple of seven. After a leap day it moves forward two. That is why the calendar does not simply repeat every seven years; the full Gregorian pattern of dates and weekdays repeats every 400 years.

Annual figures. A leap year has one more working day, one more day of interest, and one more day of sales. Year-over-year comparisons that ignore this are off by about 0.27 percent.

Software. The most common leap-year bug is implementing only the first rule. It gives the right answer for every year from 1901 to 2099, so it usually goes unnoticed — and it will be wrong in 2100. Other classic mistakes are assuming a year always has 365 days, or adding “one year” to 29 February and producing a date that does not exist. (A date calculator that handles this correctly is a useful sanity check.)

Leap years and week numbers

The ISO week-numbering system has its own version of the same problem. A year is 52 weeks plus one day, or plus two in a leap year, so every five or six years those leftover days add up to an extra week and the ISO year has 53 weeks instead of 52.

Not to be confused with leap seconds

A leap day corrects the mismatch between the calendar and the Earth’s orbit around the Sun. A leap second corrects the mismatch between atomic clocks and the Earth’s rotation on its axis. They are unrelated adjustments at very different scales: one adds 86,400 seconds on a fixed schedule; the other adds a single second whenever measurements show it is needed.

The next leap years

The next leap years are 2028, 2032, 2036, and 2040 — the 2028 calendar is the next one with a 29 February. The next century year that is not a leap year is 2100 — the first time the century exception will apply since 1900. You can check any year, month by month, in the calendar.

More related articles