The Times They Are a-Changin’

The number of days in a year is 365 or 366… or more or less

Kevlin Henney
4 min readApr 27, 2020

In jumping from calendars that are a distance apart and moving at different speeds, you need to change gears to get the two in sync. This can upset the regularity of our expectations:

I said that calendar years have one of two day counts: 365 and 366 days. In the Gregorian and Julian calendars this is true… but when jumping from one system to another, truth is more fluid.

In the default case you take the baseline of 365 days and add an optional leap year. In exceptional cases, such as changing from the Gregorian to the Julian calendar, you lose a few days to mesh gears. For example, instead of 366 days, 1752 in the UK had 355. The same happened in Denmark and Norway in 1700. 1753 in Sweden and Finland had 354 days instead of 365. In 1918, Russia’s year was shortened to 352 days.

The upper limit of 366 is enshrined in the C standard library. The tm data structure, which is used for representing dates and times (and is not without its problems), permits the day of the year, tm_yday, to take values inclusively from 0 to 365, which accommodates a count of 366 days.

Software written in C forms the foundation (and a fair portion of the load-bearing structure) of most software stacks in the world. Having an international standard that defines precisely what you can and can’t expect from the language and its library puts this foundation on firmer ground.

What this [0, 365] constraint means in practice is that if you want to represent a year with 367 days, you cannot do so in a conforming C implementation. This sounds like a theoretical problem, so nothing to worry about, right? Maybe. Maybe not. Keep in mind that in theory there is no difference between theory and practice, but in practice there is. Let’s return to 18th-century Sweden.

Anderson’s law states that

I have yet to see any problem, however complicated, which, when you looked at it in the right way, did not become still more complicated.

Poul Anderson could well have been describing working with different calendar systems. Sweden originally chose a very, umm, unorthodox and, let’s say, ‘creative’ approach to switching to the Gregorian calendar. It would be fairer to say that it was more migrating than switching. Migrating slowly.

The plan was there would be no leap days from 1700 to 1740. Every year would have exactly 365 days and February would always have exactly 28 of them. Slowly, like a geologically paced version of the waltz scene in 2001: A Space Odyssey, the Swedish calendar would line up and dock with the Gregorian calendar. For a period of 40 years Sweden would be out of sync with both Julian and Gregorian calendars, but there would be no fault lines or sharp shocks to the calendar. That was the plan.

It is said that no plan of battle survives contact with the enemy, and it was indeed war that derailed this effort. As planned, the Julian leap day was omitted in 1700, putting Sweden a day apart from other countries using the Julian calendar. But it was not omitted in 1704 or 1708. The Great Northern War against Russia and its allies distracted from domestic efforts such as administering changes to the calendar. In 1711, Charles XII called time on this Swedish exceptionalism, so that in 1712 Sweden switched back to the Julian calendar.

The 30 days of February 1712 in Sweden (Wikimedia Commons)
The 30 days of February 1712 in Sweden (Wikimedia Commons)

How Sweden switched back is where C’s assumption breaks: 1712 was a double leap year. Not only did Sweden restore 29th February: it threw in 30th February for good measure. 1712 had 367 days. Assumptions are the barefoot-trodden Lego-bricks-in-the-dark of knowledge. You don’t know they’re there until you step on them.

Generally, it’s a good idea to deploy large changes incrementally. But against any general guideline there are specific exceptions. This is one of them. If you plan to switch calendars, switch calendars. No half (or fortieth) measures. Do or do not, there is no try.

In 1753 Sweden changed to the Gregorian in a single movement. In 1967 Sweden changed from driving on the left-hand side of the road to driving on the right. The change was made on 3rd September, Dagen H; it was not made gradually.



Kevlin Henney

consultant · father · husband · itinerant · programmer · speaker · trainer · writer