How it is worked out
leap if divisible by 4, except centuries, unless divisible by 400
Why it is done this way
The Earth takes about 365.2422 days to orbit the Sun, so a 365-day calendar drifts by almost a quarter day a year. Adding a day every four years overcorrects slightly, which is why century years are skipped — and skipping all of them overcorrects the other way, which is why those divisible by 400 are kept.
Step by step
- Is the year divisible by 4? If not, it is not a leap year
- If it is, is it divisible by 100? If not, it is a leap year
- If it is divisible by 100, is it divisible by 400?
- If yes, it is a leap year; if no, it is not
What is worth knowing
The three-part rule leaves the calendar accurate to about one day in 3,200 years, which is why nobody has needed to fix it since 1582. The case that catches people out is the century: 1900 was not a leap year and 2000 was, which broke a lot of software written by people who only implemented the first two rules. The leap day is 29 February, and it is added because losing a quarter day a year would drift the seasons by a month within a century and by half a year within six.