Every four years, the Gregorian calendar gives us an interesting phenomenon called a “leap year.” The result? Countries that follow the Gregorian calendar end up with an extra day on the calendar: Feb. 29.

So why does this chronological quirk hit every four years? It actually takes Earth 365.242190 days to orbit the sun, leaving an “overflow” of five hours and 49 minutes. As Jackie Faherty, an astronomer at the American Museum of Natural History in New York, told NPR, “…that .242190 days to go around the sun is the entire reason why we have a leap year.”

The Gregorian calendar we use today began by papal decree in 1582, and the first Leap Day took place in 1584. In London in 1751, Aaron Hawkins wrote a pamphlet explaining the mathematical basis for the leap year and the need to make up for the five hours and 49 minutes that go uncounted in an ordinary year.

Both the 16th-century pope and his 18th-century champion were unknowingly preventing a headache for future computer scientists, who now benefit from their precision when programming systems.

Now to shake things up a bit: leap years don’t *always* occur every four years. The rules are actually slightly more complicated:

- If the year is evenly divisible by four, it
**is**a leap year, unless - …the year is also evenly divisible by 100, in which case it
**is not**a leap year,*unless* - …the same year is also divisible by 400, in which case it
**is**a leap year.

This means that programmers have to create a leap year function that takes a single integral argument (the year) and determines whether the year is a leap year. If programmers did not take this into account when setting up systems, it would throw off entire programs every four years, with a cumulative effect over time.

In theory, the need for leap years is not limited to Earth; if humanity ever settles on Mars, for example, we’ll have to hash things out all over again. But our calendar says that’s a problem for another day.