Skip to main content
Basics

Leap Year

leap year

Overview

A leap year adds one extra day, February 29, to the calendar, making the year 366 days long instead of the usual 365. Earth's orbital period is approximately 365.2422 days, so without this correction the calendar would drift by about one day every four years, eventually misaligning the seasons with the months.

Gregorian Calendar Rules

The Gregorian calendar determines leap years with three rules: (1) a year divisible by 4 is a leap year; (2) however, a year divisible by 100 is not a leap year; (3) except that a year divisible by 400 is a leap year. Under these rules, 2000 was a leap year (divisible by 400), 1900 was not (divisible by 100 but not 400), and 2024 was a leap year (divisible by 4).

Programming Pitfalls

Leap year bugs are surprisingly common in software. Typical examples include incorrect age calculations for people born on February 29, ambiguous "one year later" logic (is the anniversary of 2024-02-29 on 2025-02-28 or 2025-03-01?), and incomplete leap year checks that forget the 100-year or 400-year exceptions. Microsoft Azure experienced a major outage on February 29, 2012, caused by a leap year-related bug in certificate expiration logic.

XB!LINE

Was this article helpful?

Related Terms

Related Articles