Leap Year Rules: Why Not Every Year Divisible by 4 Is a Leap Year
Most people learn one rule at school: if the year divides by 4, it is a leap year. That rule is right for every year anyone alive today has lived through, which is why it feels complete. It isn't. The year 1900 divided by 4 and had no 29 February, and 2100 will skip it too. The full Gregorian rule has three parts, and each one exists to fix a specific, measurable error.
Why leap years exist
A calendar year has a whole number of days, but the seasons don't. The cycle that brings spring back each year, the tropical year, averages about 365.24219 days, or 365 days, 5 hours, 48 minutes and 45 seconds.
If every year had 365 days, the calendar would fall behind the seasons by almost a quarter of a day each year. That adds up to about 24 days per century. After roughly 750 years the error would reach six months, and July would land in the northern winter. A leap day every few years lets the calendar catch up.
The three-part rule
The Gregorian calendar, used for civil dates almost everywhere, decides leap years like this:
- If the year is not divisible by 4, it is a common year of 365 days. Example: 2027.
- If it is divisible by 4 but not by 100, it is a leap year of 366 days. Example: 2028.
- If it is divisible by 100, it is a leap year only if it is also divisible by 400. So 2000 was a leap year and 1900 and 2100 are not.
In code, the whole test fits in one line. This version works in C, Java and JavaScript:
isLeap = (y % 4 == 0 && y % 100 != 0)
|| (y % 400 == 0);
Python has it built in as calendar.isleap(year). Writing your own is a classic source of bugs, because the simple y % 4 == 0 test passes every test case from 1901 to 2099 and only fails at the century years.
1900, 2000 and 2100 side by side
| Year | รท4 | รท100 | รท400 | Leap year? |
|---|---|---|---|---|
| 1896 | Yes | No | No | Yes |
| 1900 | Yes | Yes | No | No (365 days) |
| 1904 | Yes | No | No | Yes |
| 2000 | Yes | Yes | Yes | Yes (366 days) |
| 2026 | No | No | No | No |
| 2028 | Yes | No | No | Yes |
| 2100 | Yes | Yes | No | No (365 days) |
| 2400 | Yes | Yes | Yes | Yes |
The century rule removes three leap days in every 400 years. That leaves 97 leap years per 400, so the average Gregorian year is 365 + 97/400 = 365.2425 days. Counting it out, the 20th century (1901 to 2000) had 25 leap years, and the 21st (2001 to 2100) will have only 24.
Because 2000 was divisible by 400, it behaved like an ordinary leap year, and the last real exception was 1900. Nobody now living will have seen a year divisible by 4 skip its leap day. That changes in 2100, and any software still using the 4-only shortcut will put a 29 February where none exists.
Why the Julian calendar wasn't good enough
The "every fourth year" rule is the Julian calendar, introduced by Julius Caesar in 45 BC. Its average year is exactly 365.25 days, about 11 minutes and 15 seconds longer than the tropical year. That sounds trivial, but it adds up to one full day every 128 years.
By the 16th century, the Julian calendar had drifted about 10 days against the seasons, and the spring equinox, which sets the date of Easter, was falling on 10 or 11 March instead of 21 March. Pope Gregory XIII's bull Inter gravissimas, dated 24 February 1582, fixed both problems at once:
- It deleted ten days: Thursday 4 October 1582 was followed by Friday 15 October 1582 in Spain, Portugal, the Papal States and Italy.
- It added the century rule, so the calendar would not drift again.
Other countries switched later. Britain and its colonies waited until 1752, by which time 11 days had to be removed from September. Our post on the Julian to Gregorian switch covers the country-by-country story.
The Gregorian rule is not perfect either. Its 365.2425-day year is about 27 seconds too long, which works out to an error of roughly one day every 3,000 years. That is far below anything that matters for civil life, and the length of the tropical year itself changes slowly over such spans.
Why the extra day is in February
February was already the Roman calendar's place for corrections. Before Caesar, the Republic kept its calendar in line by inserting an occasional extra month, Mercedonius, after a shortened February. Caesar's reform kept the correction there, but it did not add a 29 February. In a Julian leap year they counted the sixth day before the Kalends of March, 24 February, twice. That doubled day is the origin of the word bissextile, still used for leap years in French (bissextile) and other languages.
Treating 29 February as the leap day is a later convention. Some countries only changed the official leap day in modern times: Sweden and Finland moved it from 24 to 29 February in the late 1990s. The number of days in the year is the same either way.
Lotus 1-2-3 treated 1900 as a leap year, and Microsoft Excel copied that so its date serial numbers would match. Microsoft documents that the error was never fixed because correcting it would shift almost every stored date by one day. Excel handles every other year, including 2100, correctly.
How leap years change date calculations
Worked example: a 90-day stay
Many entry permits allow a stay of a fixed number of days, counting the arrival day as day 1. Take a 90-day stay starting on 10 January:
- 2027 (common year): day 90 is Friday 9 April 2027.
- 2028 (leap year): day 90 is Saturday 8 April 2028.
The extra day in February uses up one day of the allowance, so the last permitted day comes one calendar date earlier. Anyone who counts "three months" instead of 90 days, or reuses last year's dates, can overstay by a day. You can check spans like this with the timeandcal Date Calculator, which counts days between any two dates and includes 29 February automatically. Note that it counts the difference between dates, so add one if the rule counts both the first and last day.
Adding a year to 29 February
Ask a program for "29 February 2024 plus one year" and it has to make a choice, because 29 February 2025 doesn't exist. Python's date(2024, 2, 29).replace(year=2025) raises a ValueError. Other libraries quietly return 28 February or 1 March. If your system handles subscriptions, contract anniversaries or age checks, decide the rule deliberately and test it with a 29 February input.
Leap day birthdays
People born on 29 February, sometimes called leaplings, raise the same question in law: in a common year, do they turn a year older on 28 February or 1 March? There is no single answer. Some jurisdictions and agencies use 28 February, others 1 March, and many statutes don't address it at all. New Zealand's Age of Majority Act 1970, for example, says only that a person reaches an age at the start of the relevant anniversary of their birth. For a driving license, benefit or legal age question, check the rule of the specific authority involved. Our guide to calculating your age in days shows how leap days affect exact age counts.
Interest and day counts
A leap year has 366 days, so anything priced per day changes slightly. Financial contracts state a day-count convention for this reason. Under "Actual/365 Fixed", a loan earns 366/365 of a year's interest over a full leap year, while "Actual/Actual" conventions divide by 366 for days falling in the leap year.
Leap years are not leap seconds
The two are often confused, but they fix different problems:
- Leap years keep the calendar aligned with Earth's orbit. They follow a fixed rule, so every leap year for centuries ahead is already known.
- Leap seconds kept UTC within 0.9 seconds of Earth's slightly irregular rotation. They were decided by the International Earth Rotation and Reference Systems Service (IERS) a few months ahead. The last one was added on 31 December 2016, and in October 2026 the General Conference on Weights and Measures decided that UTC becomes continuous from 20 May 2027, with the allowed gap raised to one hour, so no more leap seconds are expected for a very long time.
Our leap seconds explainer covers why Earth's rotation needs a separate correction.
Quick checklist
- Use the full test: divisible by 4, except century years, unless divisible by 400.
- 2028 and 2032 are leap years. 2100 is not. The next century leap year is 2400.
- Use a library function such as
calendar.isleap()instead of writing your own. - For permits and deadlines counted in days, count days, not months, and check whether 29 February falls inside the span.
- Test any date code with 29 February and with the year 2100.
Frequently Asked Questions
Sources
- Gregorian calendar โ Wikipedia
- Mercedonius (Roman intercalary month) โ Wikipedia
- Ante diem bis sextum Kalendas Martias โ British Sundial Society
- Excel incorrectly assumes that the year 1900 is a leap year โ Microsoft Learn
- Age of Majority Act 1970, section 5 โ New Zealand Legislation
- Resolution 4 of the 27th CGPM (2022): on the use and future development of UTC โ BIPM
Count days across leap years
The timeandcal Date Calculator counts the days between any two dates, with 29 February included automatically in leap years.
Open Date Calculator โ