Last time, we implemented a calendar system that can handle the Gregorian, French Revolutionary, and Islamic calendars. We’re missing two big ones: the Chinese and Hebrew calendars.

### The Chinese calendar

The traditional Chinese calendar is lunisolar. Lunar months, like the Islamic calendar, so it should be a piece of cake, right?

Unfortunately, no. Whereas the Islamic calendar added a leap day, the Chinese calendar uses instead two cycles. Within each cycle, month lengths alternate between 30 and 29 days — an even-numbered month has 29 days; an odd-numbered month has 30. There are two cycles, one of fifteen and one of seventeen months — in the former, months average 29.533 days; in the latter, months average 29.529 days. The actual length of a lunar (synodic) month is 29.531 days, so that works out to be slightly more accurate.

(Quibbling about hundredths of a day might seem a bit silly, but calendar systems have to work across thousands of years.)

To make matters worse, the Chinese calendar isn’t purely lunar, like the Islamic calendar; instead, it’s lunisolar. The years have to stay relatively consistent with the seasons. To enforce this, a leap month is added as necessary: if a year has 13 new moons, it’s a leap year.

### For masochists: the Hebrew calendar

The Hebrew calendar uses lunar months, like the Islamic one. No sweat, right?

Except it’s a lunisolar calendar, not just a lunar calendar. To keep up with the seasons, it’s got leap *months*. Out of every nineteen years, seven have an extra month — the last month, Adar, is renamed to Adar II, and before it, we insert Adar I. (The holidays normally in Adar appear in Adar II on leap years, which is why we know that leap years don’t insert Adar II.)

The most straightforward way to model this is to have a month, Adar, that is 29 days long normally, but 0 days long on leap years. Then we add two months, Adar I and Adar II, for leap years. But this messes up our numeric notation something fierce. With the previous three calendars, the month number functioned as an index into a months array. Plus, if you want to have a recurrence, you need something to tell you that Adar is the same as Adar II.

Now, before we try to solve this problem, let’s talk about the *other* big problem. The Hebrew calendar, like most, is strongly influenced by its society’s religion. Judaism has strong restrictions on what you can do on Shabbat (Saturday). Preparing for Shabbat takes some work. Yom Kippur has similar restrictions. It would be burdensome to have Yom Kippur adjacent to Shabbat, so the calendar is adjusted to ensure that doesn’t happen. Conversely, Rosh Hashanah should not occur on Shabbat, because that would interfere with the holiday.

In a normal year, the month of Cheshvan has 29 days, and Kislev has 30 days. In an abundant year, Cheshvan gains an extra day; in a deficient year, Kislev loses a day. The rule that people use for simplicity is a simple table from when the new moon in Tishrei falls, to whether the year should be deficient, normal, or abundant.

We have one last problem. Rosh Hashanah is the New Year festival. It occurs in Tishrei, the seventh month. So if you’re counting, the months go from 7 to 12 (or 13 in a leap year), followed by 1 through 6.

The Islamic calendar repeats exactly every 30 years. The Gregorian and French calendars repeat every 400 years. The Hebrew calendar repeats every 689,472 years.

We have six types of year to worry about with the Hebrew calendar, not two like everything else.

One final caveat: like the Islamic calendar, some communities use observational methods to determine when months change. We’re not worrying about that.

Next time, should we get there, we’ll talk about how to calculate lunations and how the hell we’ll deal with the Hebrew calendar.