Counting Moons

Sep 2013 republished Jul 2019

Lunar and Solar Calendars

Most calendars are built around approximations of astronomical cycles. The earth's period around the sun is approximately 365.25 days. The Gregorian calendar approximates that to 365. The lunar cycle is approximately 29.53 days. The Hijri calendar counts 12 of those and calls it a year. Some calendars try to track both, fudging the difference between the two approximations every few years with an extra month.

What almost all calendars have in common is that they deal with mapping a non-integer value to an integer number of days, since we usually want years and months to start and end at day boundaries. The Gregorian deals with the leftover 0.25 day by adding a leap day every fourth year.

The Hijri Calendar

So how does the Hijri calendar deal with the fraction in the moon's cycle? It turns out there are multiple accepted schemes to decide when it's a new month.

What's common in all of them is that they are answers to the question of whether to round 29.53 up or down. What's also common between them is the error is also bounded to about 2 days, since that's roughly how long it takes for a waning crescent visible to the human eye to become a waxing one visible to the human eye.

These schemes can be put in 3 categories of how they determine the moon's cycle. Observation, approximation, and calculation. Let's take each in more detail in turn.

1. By observing it

How do you know it's a new month? Look up.

This is the traditional way of deciding on a new month, and often the official one to be used by Islamic authorities to declare important events such as رمضان (the fasting month) or ذو الحجة (the pilgrimage month). It's simple enough: if you can see the new moon on the 29th day, this month is 29 days. Otherwise, it's 30.

This is simple enough but has a couple flaws that make it a bit inconvenient.

The first is weather. Apart from the obvious issue of clouds or sandstorms occluding the moon, there are also the effects of refraction across the horizon.

The second issue is this method's locality. Answers are different in different places. It could be the 2nd day of the month in Cairo but the 1st in Damascus. This makes planning and comparing events that took place in different places complicated.

2. By approximating it

So what if we agreed to approximate the month lengths, and accept that they might be wrong by a day or two every now and then, as long as it eventually corrects itself. That is, on average, the months accurately track the moon. This is the analogue of the Gregorian calendar's leap day system applied to the lunar calendar.

The lunar month's fraction (29.53) are not as nice as the solar year's ¼ day, which means the cycles will have be a little more complicated to repeat cleanly. But that didn't stop people, and the result is a 30-year cycle first described in the 2nd century AH (8th century CE).

The scheme is as follows: if one alternates months of 30 and 29 days, then adds 11 whole days every 30 years, that brings months back in sync with the moon. All that remains is to agree where exactly to sprinkle these 11 days. The most popular "table" for this is to add a day at the end of the 2nd, 5th, 7th, 10th, 13th, 16th, 18th, 21st, 24th, 26th, and 29th year. This is what Microsoft and Apple both use for their default Hijri calendars.

Of course, other tables exist. R.H. van Gent maintains a number of informative pages on these tables and their history.

3. By computing it

We have fairly accurate models of the lunar phases. This means we can compute down to the second when a new moon will be born. It's usually not visible to the human eye for at least a few more hours, but if we ignore that detail, and ignore the detail about weather effects like refraction mention above, we can use that moment for defining the new month.

All we need to do is agree on a location, and a time of day as the cut-off point for the new month. This is precisely what the أم القرى (Umm AlQura) calendar does. It picks Mecca as the location, and it picks sunset as the cut-off time. Sunset because that's traditionally when the day starts. It's also known as Italian time.

Putting it together

I learned all this while putting together a Hijri calendar face for the Pebble watch. The source code is available, but I'm not sure about the binaries on the old Pebble marketplace. This is what it looks like:

That app also implements a very minimal version of the Unicode text shaping and bidirectional text algorithms, but that's a subject for another post.

For any comments or corrections email or tweet!