Here’s the problem: the tropical year, the time it takes the Earth to go through a complete cycle of seasons, is 365.2422 days long (to four-decimal accuracy).
If every calendar year were 365 days long, then the missing 0.2422 days would add up from year to year, each year starting a little earlier relative to the changing seasons. It would take only 120 years for the calendar to be a month adrift from the season.
The Roman Republican calendar had a standard year of just 355 days. Every few years an additional month was added, bringing the year up to 377 or 378 days. With the right frequency (about 11 long years to every 13 standard years), that system could have kept the calendar year aligned with the tropical year on average, though with pretty large excursion from year to year. Trouble was, the decision whether or not to add additional months was driven as much by politics and superstition as it was by astronomical accuracy, and on occasion the Republican calendar drifted as much as four months away from seasonal alignment.
Julius Caesar came to power when the Roman calendar was awry by more than two months. After taking advice from the Greek astronomer Sosigenes of Alexandria, he came up with a plan to get the calendar back into alignment with the seasons, and to keep it that way. First, he decreed that 46 BC should be 445 days long. He then established the familiar pattern of leap years we know today, by creating a regular year of 365 days, and adding an extra day to February quarto quoque anno, “every four years”. That made the average calendar year 365.25 days long, tolerably close to the desired 365.2422.
Caesar was assassinated in 44 BC, and confusion immediately reigned. Roman counting was commonly inclusive—for instance, they used what we would call an eight-day week, from one market day to the next, but they called it a nundinem, derived from nonus, “ninth”. They counted nine days because they included the market day at the beginning and at the end of the week as being part of the same week. So Caesar’s quarto quoque anno was implemented as a three-year cycle until 9 BC. At that point his successor, Augustus (having had the necessary arithmetic drawn to his attention), started the correct four-year cycle, and tried to get things back the way Julius had wanted them by skipping the leap years in 5 BC, 1 BC and AD 4 in order to get rid of the effect of the excessive leap years that had accumulated so far.
Julius Caesar’s calendar years of 365.25 days (called Julian years, in his honour), then ticked away steadily from AD 8 until 1582. And the difference of 0.0078 days between the Julian year and the tropical year mounted up steadily, so that by 1582 the calendar had moved more than 12 days out of register with its original seasonal position.
This was a problem for the Christian Church. The date of Easter was tied to the seasons—specifically the northern spring equinox—but for the purpose of calculating the specific date of Easter each year, the spring equinox was represented by a date, March 21. This date had been correct at the time of the Council of Nicaea in AD 325, when the standard computation of Easter was agreed, but by the sixteenth century the calendar had drifted so that the vernal equinox was occurring on March 11. Martin Luther pointed out that, in 1538, Easter should have been celebrated on March 17, according to the timing of the vernal equinox, but had been pushed to April 21 because of the slippage in the Julian calendar.
Pope Gregory XIII, advised by astronomers Aloysius Lilius and Christopher Clavius, came up with a solution.* Like Caesar’s calendrical intervention previously, there were two parts to the fix—one to get the calendar back into alignment with the seasons, and the other to prevent it drifting again. The details were promulgated in the papal bull Inter gravissimas. To realign the seasons (specifically, to get the vernal equinox back to March 21) ten days were to be omitted from the month of October—October 4, 1582 was to be followed by October 15.
To tighten the approximation of the calendar year to the tropical year, the rule for leap years was subtly tweaked, by dropping three leap years every four centuries. According to the Julian calendar, every century year was a leap year; according to the new Gregorian calendar, only century years exactly divisible by 400 were to be leap years. So 1600 was a leap year, 1700, 1800 and 1900 were not, and 2000 was (you may remember) a leap year. Having just 97 leap years in every four centuries brings the length of a mean calendar year down to 365.2425 days—just 0.0003 days longer than the tropical year.
Catholic countries all made the change as instructed, though some lagged a little behind the dates set out in Inter gravissimas. Rulers and governments in Protestant and Orthodox countries were keen not to be seen as toeing the papal line, and so in some places the improvement took a long time to be adopted. The two calendars therefore ran in parallel for several centuries, with writers having to be careful to mark their dates “O.S.” (for “Old Style”) or “N.S.” (for “New Style”).
Great Britain and its colonies eventually made the change in the eighteenth century, by which time eleven days† had to be dropped—the Julian calendar had drifted another day ahead of the Gregorian calendar by observing a leap year in 1700. In Britain, September 2, 1752 was followed by September 14. (This eventually led to the renaming of a butterfly. At that time the April Fritillary was so called because of its early hatching; but the change in the calendar shifted its peak hatching period into May. It’s nowadays called the Pearl-bordered Fritillary.)
Russia held out until 1918, by which time the Julian leap years in 1800 and 1900 meant they had to drop a total of 13 days, which they did between January 31 and February 14. This had the unfortunate consequence that the anniversary of the October Revolution had to be celebrated in November.
Sweden tried a different approach, with a plan to drop all leap years between 1700 and 1740, thereby making the necessary eleven-day shift gradually. Unfortunately, after missing the leap year in 1700, they observed leap years in 1704 and 1708, getting stuck a day ahead of the Julian calendar and ten days behind the Gregorian. At this point they seem to have thrown their hands in the air and declared the whole thing to be a bad idea. They shifted back into synchrony with the Julian calendar by having both a February 29 and a February 30 in 1712.
(Sweden eventually made the Gregorian shift in the conventional manner, by dropping eleven days in February 1753.)
* It’s of course depressingly predictable that the calendars have been called Julian and Gregorian, after the powerful men who legislated the changes, rather than Sosigenean and Lilian, after the clever men who worked out the details.
† There seems no truth to the story that people rioted in Britain because they believed the eleven days were being removed from their lives. There were riots in the election year of 1754, and the recent calendar reform was one of the political hot potatoes of the time; there was also an issue that some people were paying tax and rent for a full quarter, while being denied wages for the missing eleven days.