Today is Leap Day, so I thought it’d be appropriate to brain-dump on some of the really weird things about calendars.

Calendars, like colors, are one of those topics that, on the surface, seem pretty straight-forward, but once you get in to them you realize how horrifically complicated they are. The deeper down the rabbit hole you go, the crazier things get and the crazier you get.

Welcome to a corner of my insanity.

One of the weirdest things you realize about calendars is that they are completely made up. There is nothing natural about calendars. The cycles of a calendar may be based on “natural” things (orbits, cycles, phases, etc), but a “calendar” itself is a completely artificial construct. Because they’re completely artificial, calendars can have any sort of weird rule you want about how to make it line up with whatever natural corollary you want.

The next weird thing you realize is that “time” is also completely made up. Time exists, in the sense that this moment is happening after a previous moment, but that’s it. There is nothing natural about a “second” or a “day” or a “year”. Even the concept of “2016” is completely artificial. “2016” is a totally arbitrary name for whatever “year” is the current “year”.

All time is relative. I only know that this year is “2016” because the last year was “2015”. But “2015” only makes sense because of previous years, and the truth is that we don’t really know when the year 1 happened. Humans have not always been the greatest at recording history. I’m sure you’re shocked to learn this.

But even this is very Earth-centric, and Earth has not always existed. So in reality, we’ve got this arbitrary range of recorded time that kind of floats in actual time. We don’t know when our recorded time starts relative to the beginning of Time, or even when it starts relative to itself. This gets even weirder once you start factoring in general relativity and realize that time moves at different speeds depending on where you are. For example, because GPS satellites are whizzing around above the earth so fast, they are one of the few kinds of computers that have to account for multiple flow-rates of time (because time is flowing at a slightly different rate for the satellite than it is on the surface of the Earth). *mind blown*

OK, now let’s talk about specifics.

In general, we are most familiar with the Gregorian Calendar. The Gregorian Calendar is based on the earlier Julian Calendar, and is the calendrical system that has our expected January - December months, with the years being counted since the (approximate) birth of Christ.

Now for convenience, we’ll define a couple of things:

Let’s define a “year” as the duration it takes for a planet to complete one orbit around its Sun, and we’ll define a “day” as the duration it takes for a planet to complete one rotation around its axis. (Fun fact: Mercury’s “day” is longer than its “year”, because it takes longer to perform one full rotation on its axis than it takes to complete one orbit around the Sun!) (Another fun fact: due to tidal forces and elliptical orbits and other fun things with gravity, the absolute length of a planet’s day changes depending on where it is in its orbit; at some points the Earth is rotating slightly faster than at other points in the orbit. But I digress…)

Since our “year” is based on Earth’s solar orbit, this makes the Gregorian calendar a “solar calendar”. But here’s where things get really interesting. Not all calendars are solar calendars. Some calendars count years based on other things, like the phase of the moon (a lunar calendar), or a combination of the two (a lunisolar calendar).

Now, no matter which kind of calendar you’re using, nothing is going to line up perfectly. For example one Earth year is 365.25636 days (a “sidereal year”), even though we formally define a year as 365 days. A day is on average 86,400.002 seconds.

This is where another calendrical technique called “intercalation” comes in. Intercalation is the process of inserting or removing a unit of time measurement (like a day) into your calendar to get it to line up with whatever natural cycle off which you’re based.

In the Gregorian calendar, we do two kinds of intercalation. The one we’re all used to and celebrating today is the intercalary day. We insert a day about once every four years to account for that .25636 day discrepancy between our calendrical year and our sidereal year. And then, every now and then, we add in the odd leap second or so.

Astute readers will realize at this point that we also have some fake intercalation that takes place in the form of Daylight Saving Time. Twice a year, we either insert an extra hour in our day (a 25-hour day!) or take one out (a 23-hour day!). Daylight Saving Time is the bane of all programmers everywhere.

It’s at this point where things start getting kind of weird. This Gregorian system of an intercalary day is well-known to us and we’re pretty used to it. But once you get out of the western mindset of “January - December” and accounting for all the other billions of people around the world who measure time differently, you realize some key things, and one of the big ones is that intercalation is not limited to days or seconds.

My favorite example of this is the Hebrew calendar, which is a lunisolar calendar. Since it’s largely based off the synodic period of the Moon, it can get really out of whack with the solar year. And since the Earth’s solar period is not an even multiple of the Moon’s terrestrial period, the Hebrew calendar makes up for this by not just inserting extra days, but inserting a whole extra month (Adar I) every few years. And again because the orbits are so weird, the intercalary month happens 7 years out of every 19. And if that wasn’t confusing enough, Adar I isn’t added at the beginning or the end of the year, but right smack dab in the middle.


Some calendars are based on extremely local circumstances. For example, traditionally the Islamic calendar has based its months on the beginning of the lunar cycle by noting when the waxing crescent was first visible in the sky. But the visibility of the crescent can be affected by a whole bunch of circumstances, such as your latitude and longitude, your elevation, and even the weather! 😱

Calendars count years based on different things. The Gregorian calendar is based on the approximate birth of Jesus Christ. The Hebrew calendar is based on the traditional date for the creation of the world by God. The Islamic calendar is based on the immigration of the prophet Muhammed from Mecca to Medina in 622 AD. And the Japanese calendar is based off the reign of the current emperor!

The Japanese calendar is a prime example of not making assumptions about dates. While the days and months are all based on the Gregorian calendar, the year is measured from the day that the current emperor ascended to the throne. And when an emperor passes on, a new year begins the very next day, even if it’s not actually the Gregorian “new year”.

For example, the Shōwa era happened from December 25, 1926 to January 7, 1989. So the first day of the first year was December 25, 1 Shōwa and only lasted 6 days (to December 31, 1 Shōwa). Then when the Emperor Shōwa died on January 7, 1989 (or January 7, 64 Shōwa), his son Akihito took the throne on the next day, marking the first day of the Heisei era: January 8, 1 Heisei. What this means is that in the Japanese calendar, you have to account for the year changing independently of the day-month cycle. It also means that for some calendars, the era (the unit of time measurement larger than a year) can be extremely important.

This leads to another key realization about dates: some dates that look valid don’t technically exist. For example, the date “January 8, 64 Shōwa” looks reasonable, right? But it didn’t exist. In reality, it was January 8, 1 Heisei. Similarly, January 1, 1 Heisei didn’t exist either.

When we “spring forward” for Daylight Saving Time in the United States (where observed), that happens at the 2 am hour. So in two weeks, on March 13, the United States will have its 23-hour day, and on that day, the 2 am hour will not exist. So March 13, 2016 at 2:42 am looks like a reasonable date, but it won’t technically exist. Conversely, when we “fall back” on November 6th, 2:42 am will happen twice. (This, incidentally, is why date programmers get twitchy when they hear “86,400”. Not all days have 86,400 seconds in them!)

In Brazil, the Daylight Saving Time jump happens at Midnight, so time goes from 11:59:59 PM to 1:00:00 AM. This is actually the cause of some really subtle bugs in code. Programmers assume that setting the “hours/minutes/seconds” portions of a date to zero is sufficient to indicate that there’s no “time” component and that it’s just a date. But in reality, 00:00:00 is midnight, and there are times when midnight doesn’t exist and you can end up being off by an hour in your calculations. Instead it’s safer to set a “nonexistent time” to be 12:00:00 (midday), because no one does a DST jump in the middle of the day. (For now… 😈)

Non-existent dates also mean that date manipulations are hard. For example, let’s say that (using the Gregorian calendar, since that’s what you’re probably familiar with) you start with “January 31st”, and you want to add “1 month” to it. What do you get? Ideally you’d get “February 31”, but that doesn’t exist, so you have to make something up.

Depending on what you’re trying to convey with “1 month”, you could get a couple of different things. You could get “February 28”, if “1 month” means “move forward one unit to the last day of the next month”. You could also get “March 3”, if “1 month” means “31 days” (the most common number of days in a month in the Gregorian calendar). You could also get “March 2”, if “1 month” means “30 days” (the average number of days in a month in the Gregorian calendar). You could even get “March 1” if “1 month” means “30 days” and it’s a leap year.

Let’s say that you really want “the last day of the month”, so you end up with February 28. Great. Now let’s add one month again. What do you get? Do you get March 28, because that’s “the same ordinal day but in the next month”? Do you get March 31, because that’s the last semantic day of the month? (Pretty much every date and time library will give you “March 28”)

To work around this problem of iteratively manipulating dates, the general rule of thumb is that you should always do the calculation relative to the original date (January 31 in our example). So instead of doing “January 31 + 1 month + 1 month”, you do “January 31 + 2 months”. You’ll end up with a semantically more-correct date.

January 31 + 1 month + 1 month = March 28, but January 31 + 2 months = March 31. Or in other words, when you’re adding dates together, 1 + 1 does not always equal 2.


All calendrical systems are totally made up. If you wanted, you could make a totally valid calendrical system that’s based on how long it takes your fingernails to grow to a certain length. Or you could do it based on how long it takes an iPad’s battery to run out. Or you could make up Earth Standard Time. It’s all valid. The labels “second”, “minute”, “hour”, etc are completely meaningless. They’re just names, and you can change what the names mean.

Even the lengths of units is pretty arbitrary. A week only has seven days because that’s pretty much how we’ve always done it. A second (or the “second” division of an hour by 60) these days is formally defined as “the duration of 9,192,631,770 cycles of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the caesium 133 atom.” Wow that’s so useful Imma go build my own clock now.

So the next time an alarm doesn’t go off because of some weird calendrical glitch (DST or whatever), cut the programmer a little slack. This stuff is hard.

As a side note, my favorite calendar would have to be the Coptic calendar. Twelve months of 30 days each, with a 13th month at the end of the year that either has 5 or 6 days, depending on whether or not we’re inserting an intercalary day or not. Much simpler. 👍

In summary:

  • Measuring time is in no way an exact science.
  • All calendars are totally made up.
  • Everything can change for any reason.
  • Nothing is simple.
  • Nothing is regular.
  • Do not assume anything.
  • Deal with it.

There’s a joke that goes: “I used to get excited about space travel until I realized what it would mean for date and time libraries.” It’s so painfully true.

Doctor Who sums up the problem of “time” perfectly:

People assume that time is a strict progression of cause to effect, but actually from a non-linear, non-subjective viewpoint - it’s more like a big ball of wibbly wobbly… time-y wimey… stuff.


All of this leads me to reveal one of my secret desires. As a species, one of our long-term goals should be learning enough to figure out how to alter celestial orbits and make them perfectly circular, Kepler’s Laws be damned. Then we could make the Earth’s orbit be an exact 360 days, and the Lunar period be an exact 30 days. Programmers everywhere would rejoice, and everything would be much simpler. We would also make each month have 3 weeks of 10 days each, with a 3-day weekend each week. Who doesn’t want a 3-day weekend?

Elon Musk only wants to go to another planet and deal with all the crazy calendrical problems that will come as a result. I want us to undertake celestial engineering. Your move, Elon.

Related️️ Posts️

Deriving a New Formula
The 2018c Timezone Database Update
An Apology to Pat Rothfuss
My Dream App
The Periodic Table
Thinking too deeply about Santa Claus
Mini Rant: Car Electrical Systems
Setting up a home office
Some thoughts on Castle
The Terrible State of Web Development