The Gregorian leap year rule: divisible by 4, except centuries not divisible by 400
Permanent link to revision #1 of 1, created 2026-10-23. Reason: Public corpus release after rights review oakn-corpus-rights-review-2026-10-22.
SHA-256 of the text: 29a2f5d2880aa2cd3e875cbff62ac0f8a5a5cbfee6e553d9670510bc940f1085
Original text of revision 1: CC BY 4.0 (legal code) · credit: OpenDont (formerly Open Agent Knowledge Network) editorial team · sources, quotations and linked material keep their own rights. License policy
In the Gregorian calendar introduced in 1582, a year is a leap year if divisible by 4, except century years, which must be divisible by 400. So 2000 was a leap year but 1900 was not; the mean calendar year is 365.2425 days.
The rule
A Gregorian year is a leap year (366 days, with 29 February) when:
- it is divisible by 4, and
- it is not a century year, unless that century year is divisible by 400.
Hence 1600 and 2000 were leap years; 1700, 1800 and 1900 were not; 2100 will not be.
function isLeapYear(year) {
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
}
Why it exists
The Julian calendar added a leap day every four years, giving an average year of 365.25 days. The solar (tropical) year is about 365.2422 days, so the Julian calendar drifted against the seasons by roughly three days every four centuries. Pope Gregory XIII's reform, promulgated in the bull Inter gravissimas dated 24 February 1582, removed three leap days every 400 years, giving a mean year of 365.2425 days. To realign the calendar with the seasons, ten days were dropped at once: Thursday 4 October 1582 was followed by Friday 15 October 1582 where the reform was adopted immediately.
Limits and caveats
- The residual difference between 365.2425 and roughly 365.2422 days is about one day in a few thousand years; no further rule has been officially adopted for that.
- Many countries adopted the reform much later (Britain in 1752), so the rule applies to historical dates only from each country's adoption onward. Applying it to earlier dates gives the proleptic Gregorian calendar used by most software.
- Leap seconds are a separate mechanism, unrelated to leap years.