Calendar

Preface

Before I start writing several blog posts about calendars, I feel I should preface this blog post by specifying why I’m writing about them in the first place. The end goal of this series is going to be several Android and Android Wear apps implementing various calendar features in different calendar systems. In particular, I want to implement smart complications1 for some of these features.

Those with an interest in horology will already be aware that the perpetual calendar is a rare and sought-after complication in mechanical watches. In digital timekeeping and especially smartwatches, this is already a well-solved problem, but I want to delve into why exactly the perpetual calendar is so difficult, and why in fact, the calendar in your phone or smart watch is less of a given than you may realise.

So by the end of this series, the reader should understand, not just how the Gregorian calendar works, but also how any calendar works, how they are implemented in software, and even in the physical world.

And also by the end of this series, I should have published multiple apps on the Google Play Store, each implementing some form of calendrical reckoning in one or more calendar systems. Possible apps in order of decreasing likelihood include:

  • A Julian date converter
  • A Discordian calendar complication (much like the *nix ddate on your wrist)
  • Alternative weekday complications (French décade, CJK 旬, Japanese 六曜, Discordian week)
  • A Chinese lunisolar calendar2
  • One or more religious observance calendars (e.g. Hijra, Jewish, Panchanga)
  • A planning calendar app and complication set (i.e. a poor man’s Google Calendar)
  • An orrery watchface, most likely a tellurium3

This (very unplanned) series likely will spiral into too much detail about horology, and so a second series more dedicated to timekeeping may spin out of this one. But for now, let’s keep to calendars. In this post I will cover the astronomical basis for calendars, that is the motion of the Sun, Moon, and Earth, relative to a backdrop of stars, while later blog posts will delve into individual calendars and their features, along with some implementations in code.

Sundial

We’re Burning Daylight

The single most important unit of time is the day. While modern sensibilities and our language surrounding time might suggest it is the hour4, it is the day upon which both timekeeping and datekeeping are built. A day is, roughly, the time it takes for the sun to return to the same position in the sky. That is to say, that a day can be defined as sunrise to sunrise, sunset to sunset, noon until noon, or even something arbitrary like 15° above the horizon on ascent.

Astute readers might note however, that sunrise and sunset don’t occur at the same time every day. In fact, even high noon, the most stable of daily solar events, moves above and below the 12 hour mark throughout the year.

So how long is a day? Well, the day we described above is called an Apparent Solar Day, i.e. the amount of time between high noons. Ancient civilisations instead used sunrise or sunset for their apparent solar days, which gave less consistent results, especially further from the equator. Using high noon stabilises days to only vary about 20 minutes throughout the year.

Instead of Apparent Solar Days, you can take the mean average of all days in a year (we’ll get to what a year exactly is later), and call it a day. Modern timekeeping is based on this Mean Solar Day, with one Mean Solar Day being stated as 24 hours, and thus hours, minutes and seconds being originally defined by their proportion of a Day.5

A Civil Day or Calendar Day, is the agreed upon period of midnight to midnight in a time zone, equal to one Mean Solar Day. So a Mean Solar Day shifted by 12 hours to start and end at midnight. This is the day that your calendar considers a day, and why your wristwatch and phone change dates at midnight.

How else can we define a day? Well the modern second is no longer defined as exactly $\frac{1}{86400}$6 of a Mean Solar Day, instead the SI second is defined according to radiation of a Caesium-133 atom. An SI day, known as an ephemeris day is 86400 SI seconds, which divorces us from the actual rotation of the Earth. This concept of counting SI seconds from an epoch serves as the basis for Ephemeris Time, which we use to track astronomical events without getting confused.

What if we did base our day on the rotation of the Earth? Well, that would be a Sidereal day, one complete 360° rotation of the Earth, relative to the fixed stars. This is about 4 minutes shorter than a Mean Solar Day, because the Earth progresses along its orbit while rotating about its axis, meaning the sun is a little bit behind where it was yesterday in the sky compared to the stars, and the Earth has to rotate just under an extra degree to complete a Solar Day.

If we were on Mars, a mean solar day (called a Sol) is about 39.5 minutes longer, due to Mars’ slower rotation.7

For the purposes of talking about calendars, we will take the Civil day as our basic day. Though we may require other definitions for certain calendars.

And the Years Keep Coming

Having covered days in detail, it’s now time to talk about the other critical solar event: the year. Much like days, these can be reckoned in numerous ways, including: Tropical (solar), sidereal, Julian (ephemeris), anomalistic, and draconic.

First, the Julian year, which like the Ephemeris day, is based on pure arithmetic. It is defined as 365.25 ephemeris days of 86400 seconds each. This is useful for calculations, but quickly falls out of sync with motions of the planets.

There are several astronomical definitions of a year, starting with the sidereal year. Like the sidereal day, which is one 360° rotation of the Earth about its axis, the sidereal year is one 360° orbit of the Earth around the Sun relative to the fixed stars8. This is equal to 365.256363004 ephemeris days, and from an Earth perspective is the time it takes for the sun to be in the same position relative to the distant, fixed stars. Prior to the development of the solar year, the seasons and progression of the year were inferred from the positions of these fixed stars in the sky, and so a sidereal year is one of the oldest concepts of a year.

The solar, or tropical year functions much like our solar day, in that it is how long the sun to return to the same position in the sky. This may sound like the same thing as the sidereal year, but it’s important to note the precession of the equinoxes, where the Earth wobbles on its axis like a spinning top, making the stars shift slowly in their positions in the sky9. This precession is why the tropical year is 365.24219 ephemeris days or 365.24217 mean solar days.

For fun, let’s now look at the anomalistic and draconic years. Anomalistic years are the duration between perihelion passages, that is to say the time between Earth’s closest approaches to the sun, at 365.259636 ephemeris days. This is useful to know when flinging stuff into space, but not much else. Draconic years, also known as ecliptic years, are the time it takes for the sun to pass through the same lunar node, which is the intersection between the sun and moon’s paths through the sky. There are two of these nodes, therefore there are two eclipses per draconic year, which has a duration of 346.620075883 ephemeris days. This one is important for eclipse hunters, as it tells you when eclipses will happen.

Leap years

You may have noticed that a year is not a whole number of days, with even the ephemeris definition being 365 and a quarter days exactly. This disconnect between days and years is the cause of leap years, with numerous systems of intercalation in use to realign the tropical year with a discrete number of days, rather than have a new year occur at six AM one year, and 12 noon the next. The exact calculation for intercalation 10 is the primary difference between the Julian and Gregorian calendars, and provides most of the complexity in any calendar system. We will discuss intercalation in fuller detail when breaking down calendars in a later post.

The Moon

Fly Me to the Moon

With both our solar events covered, it is time to look at the moon. The concept of a year gives us the seasons, with more light and heat from the sun giving us summer, and less giving us winter, but the concept of a month breaks those seasons up into more digestible chunks. Looking again to the sky, the moon and her ever-changing face is an obvious inspiration for tracking the passage of time in shorter durations compared to the passage of the seasons and the progression of the fixed stars. Like our solar events above, the moon can give us several different definitions of month.

First, our handy sidereal month, calculated by, you guessed it, how long it takes the moon to orbit the Earth relative to a fixed star. This takes 27.321661 ephemeris days, and the lunar ecliptic, or path of the moon through the night sky, is very important to Chinese astronomy.

Next is the synodic month, which is the most easily observed form of month, it is the time between two identical phases of the moon, most commonly new moon to new moon, or full moon to full moon. This has a mean length of 29.53059 ephemeris days and forms the basis for the majority of lunar calendars.

The tropical month, how long it takes the moon to reach the same point of the sky, takes 27.32158 ephemeris days, just seconds shorter than the sidereal.

The anomalistic month is measured from perigee to perigee, the moment the moon is closest to the Earth, and takes 27.55455 ephemeris days. Useful for launching rockets, but not for Earthly concerns.

The draconic month, named for the mythical dragon which eats the moon during eclipses11, is measured between ascendant crossings of the Earth’s orbital plane and takes 27.21222 ephemeris days. An eclipse can only happen at these nodes, so this, combined with the draconic year, can be used to not only calculate when eclipses will happen, but also what kind.

Thirty Days has September

A lunar month is 29 or 30 days long, to approximate one synodic month. Alternating between “full” 30 day and “hollow” 29 day months, with some accommodation for leap days, produces an accurate lunar calendar. However, 12 such months, 6 full, and 6 hollow, gives 354 days. Adding another month gives 383 or 384 days. So a calendar cannot be both accurate to the sun and the moon in one year. Lunar calendars use this 354 day lunar year, and lose synchronisation with the seasons as a result.

Purely solar calendars like the Gregorian use non-lunar ‘months’ to roughly correspond to the moon’s lunations, without actually tracking it to a degree of accuracy. This is why there’s generally one full moon every month, but occasionally two12 and occasionally none in February13 as it’s usually shorter than a synodic month. An accurate lunar calendar will only ever have one full moon per month.

Lunisolar calendars, like the Chinese Traditional calendar, try to maintain both lunar and solar accuracy, which makes them the most complex calendars in use.

Bringing It All Together

All of the above sections should give the reader a good idea of why then, calendars are so complicated. Balancing the mismatch between the lengths of days, months, and years is an intractable problem with no good solutions. Therefore any good calendar must make sacrifices in terms of accuracy and simplicity. Too simple, and it can’t be accurate. Too accurate, and no mere mortal could ever use it to plan a meeting.

And accuracy is important, as a calendar which falls out of sync with the celestial sphere causes havoc to those who depend on it. The Gregorian was adopted because the Julian fell out of sync with the seasons. The precession of Ramadan throughout the tropical year means that some years are easier to fast through than others because of the number of daylight hours during the lunar month. The confusion over when in a year religious observances like Easter or Yom Kippur14 occur are because they are lunar observances, and move relative to the inaccurate months of the Gregorian calendar.

Every calendar has its shortcomings, but through the rest of this series we can explore why those shortcomings exist, and what strengths those same systems have.

Coming Up Next

An exploration of how to build a calendar from these astronomical parts, using the Coptic/Ethiopian Calendar as a worked example of how to build a calendar system that works.

Other posts in this series:


  1. Those little detail windows on watchfaces. ↩︎

  2. This will likely be a traditional Japanese calendar because I will have an easier time with Japanese source materials than Chinese ones ↩︎

  3. Orreries map the motion of the solar system. One accurate enough to predict eclipses is called an astrarium. A grand orrery contains all the planets, at least as far as Neptune. While one that only maps the moon and Earth is called a lunarium. A tellurium maps the Earth, Moon, and Sun, and if accurate enough to be an astrarium, can be used for all sorts of calendrical reckoning. ↩︎

  4. Many languages ask the time by asking the hour, or use the same word for both. Even in English, the exact hour is dubbed O’Clock. ↩︎

  5. One day is the average of a year’s apparent solar days, from noon to noon, an hour is defined as $\frac{1}{24}$ of that, a minute $\frac{1}{60}$ of that, and a second $\frac{1}{60}$ of that. This was the original definition of the second when the Metric system was developed before it was later replaced with the SI definition used in Ephemeris time. ↩︎

  6. $\frac{1}{24} \times \frac{1}{60} \times \frac{1}{60}$ ↩︎

  7. With this in mind, our definition of a second might have been longer if life developed on Mars, as $\frac{1}{60}$ of a Martian minute, defined as $\frac{1}{60}$ of a Martian hour, being $\frac{1}{24}$ of a Sol, would make a Martian second just a few centiseconds longer than was settled on Earth. ↩︎

  8. Sidereal literally means ‘of the stars.’ ↩︎

  9. If every day you mapped out the sky and position of the sun and stars in it. The tropical year happens when the sun hits the same coordinate as last year. The sidereal year happens when the map looks identical, just rotated slightly. ↩︎

  10. inserting extra calendar days into a year ↩︎

  11. In Chinese and Japanese, a lunar eclipse is called 月食, literally moon eating, because of this. ↩︎

  12. A Blue Moon ↩︎

  13. A Black Moon ↩︎

  14. A common Rabbinical joke is to always answer 10 Tishrei to the question of “When is Yom Kippur this year?”. An answer always correct thanks to the lunar accuracy of the Jewish calendar, but wholly unhelpful to someone who can only reckon their time using the Gregorian calendar. ↩︎