How to know if a year is a leap year
Updated on June 30, 2026 · by Rafael Rossi
A leap year has 366 days instead of 365, with an extra 29 February. The rule has three parts, and the third is the one almost everyone forgets — a great deal of software included.
The full rule
- If the year is divisible by 4, it is a leap year.
- Except if it is divisible by 100 — then it is not.
- Unless it is also divisible by 400 — then it is a leap year again.
| Year | ÷4 | ÷100 | ÷400 | Leap? |
|---|---|---|---|---|
| 2024 | yes | no | — | yes |
| 2025 | no | — | — | no |
| 1900 | yes | yes | no | no |
| 2000 | yes | yes | yes | yes |
| 2100 | yes | yes | no | no |
So 1900 was not a leap year and 2100 will not be, despite both being divisible by 4. Anyone who lived through the millennium passed through the exception to the exception — 2000 was a leap year because it is divisible by 400.
Why the rule is so awkward
Because the Earth does not cooperate. One full orbit of the Sun — the tropical year — takes roughly 365.24219 days, not a round 365.
That remainder of 0.24219 days is nearly, but not exactly, a quarter of a day. All the complication grows out of that "nearly":
- The rule of 4 alone assumes 365.25 days a year — 0.0078 days too many, or 11 minutes and 14 seconds annually. It sounds like nothing, and it accumulates to 3 days every 400 years.
- Adding the century exception (removing 3 leap years per 400) brings the average to 365.2425 days — essentially on target.
- The residual error is 0.00031 days a year: one day roughly every 3,200 years. Small enough that nobody needs to worry about it.
The ten days that never existed
The Julian calendar, introduced under Julius Caesar, used only the rule of 4. With an 11-minute annual error accumulating since the first century, by the sixteenth the calendar had drifted about ten days out of step with the seasons — Easter was wandering away from the equinox.
The correction came in 1582 with the Gregorian calendar: besides creating the 100 and 400 exceptions, it required deleting ten days. In the countries that adopted the reform immediately, the day after 4 October 1582 was 15 October. The 5th through the 14th of that month simply did not exist.
Adoption was not simultaneous: Protestant and Orthodox countries took centuries to follow, and Russia only switched in 1918 — which is why the Russian "October Revolution" happened, on the Gregorian calendar, in November.
Practical consequences
- The weekday shifts by two. In a common year a date falls one weekday later than the year before; in a leap year, after February, it jumps two.
- A classic software bug. Implementing only the rule of 4 works perfectly between 1901 and 2099 — and fails at 1900 and 2100. Since almost no system is tested at those dates, the error survives for decades unseen.
- Contracts and interest. Calculations that divide by 365 come out slightly wrong in a leap year. That is why financial conventions state the day-count basis explicitly — 360, 365 or actual days.
How to test it in one line
The complete rule fits in a single expression, and it is worth knowing because this is what belongs in any code handling dates:
leap = (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0)
Order matters: testing divisibility by 400 first and returning early also works, but writing just year % 4 == 0 is the shortcut that produces the 1900 and 2100 bug.
One detail that catches anyone writing their own date arithmetic: there is no year 0 in the historical calendar — 1 BC is followed by AD 1. Modern date libraries use an astronomical numbering in which year 0 exists, precisely so the arithmetic does not break, and mixing the two conventions shifts ancient dates by a year.
Frequently asked questions
When do people born on 29 February celebrate? Legally, age-dependent effects generally complete on 1 March in non-leap years under most interpretations. In practice, choosing between 28 February and 1 March is personal — and the person has a "real" birthday every four years.
Why does February have 28 days? A legacy of the Roman calendar, which began in March and treated winter as a stretch with no named months. When January and February were appended at the end, February was left as the short month — and later gave up days to July and August, named for Julius Caesar and Augustus.
Is a leap second the same thing? No. A leap second corrects the slow deceleration of Earth's rotation, is decided case by case by an international body, and has nothing to do with the orbit. It is inserted at the end of a day, not into the calendar.
What is the quickest test? For any year between 1901 and 2099, divisibility by 4 is enough. Outside that window, apply all three rules — and that is exactly where most errors happen.