The following is an exercise in calendar design intended for teaching purposes. We will consider how a class could represent dates in the modern fixed Jewish (Hebrew) calendar, and how those dates could be converted to and from dates in a common era calendar.
The Jewish calendar is lunisolar: its months follow an approximation to the lunar cycle, while its years are kept approximately aligned with the seasons. Unlike the Gregorian calendar, it sometimes adds an entire month rather than an additional day.
Twelve lunar months average approximately 354.37 days, whereas a tropical year averages approximately 365.24 days. A calendar with exactly twelve lunar months every year would move through the seasons by approximately eleven days annually.
The fixed Jewish calendar addresses this difference by adding a thirteenth month in seven years of each 19-year cycle. The leap years are years 3, 6, 8, 11, 14, 17, and 19 of that cycle. Consequently, 19 calendar years contain 235 months: 12 months in each of 19 years, plus seven additional months.
This is related to the Metonic cycle: 235 mean lunar months are close in length to 19 tropical years. The agreement is approximate, not exact. The calendar's rules are nevertheless precise, so a program can determine leap years without making astronomical observations.
In a leap year, the additional month is inserted near Adar. The months Adar I and Adar II replace the single Adar of an ordinary year. Most months have fixed lengths of 29 or 30 days, but the lengths of Cheshvan and Kislev depend on the type of year.
| Month | Number of days |
|---|---|
| Tishrei | 30 |
| Cheshvan | 29 or 30 |
| Kislev | 29 or 30 |
| Tevet | 29 |
| Shevat | 30 |
| Adar (ordinary year) | 29 |
| Adar I (leap year) | 30 |
| Adar II (leap year) | 29 |
| Nisan | 30 |
| Iyar | 29 |
| Sivan | 30 |
| Tammuz | 29 |
| Av | 30 |
| Elul | 29 |
Thus, ordinary years can have 353, 354, or 355 days, and leap years can have 383, 384, or 385 days. These variations are not arbitrary; they follow from the rules for establishing the beginning of the year.
Knowing which years contain an extra month is not sufficient to implement the calendar. We must also determine the date of Rosh Hashanah, the beginning of the year on 1 Tishrei.
The fixed calendar uses a calculated molad, a mean lunar conjunction, rather than the actual astronomical new moon or a newly observed crescent. Its traditional arithmetic divides an hour into 1,080 parts (chalakim). The mean interval between successive moladot is 29 days, 12 hours, and 793 parts.
A set of postponement rules, known as dehiyyot, determines whether Rosh Hashanah begins on the day associated with the calculated molad or on a later day. Among other constraints, Rosh Hashanah may not fall on Sunday, Wednesday, or Friday. Other postponements depend on the time of the molad and the year in the 19-year cycle.
These rules also determine whether Cheshvan and Kislev have 29 or 30 days. An implementation must use the complete set of postponement rules; simply alternating 29-day and 30-day months or counting leap months will not give correct dates.
A possible implementation could proceed as follows:
Using an absolute day count makes it easier to calculate differences between dates and to convert between calendar systems. The same approach can be used for the Julian and Gregorian calendars, provided all calendars agree on the definition of the absolute day and the handling of the day boundary.
The calendar was not always calculated by the present fixed rules. In earlier Jewish practice, the beginning of a month depended on witnesses observing the new crescent, and the addition of a leap month could depend on seasonal and agricultural considerations. The fixed calendar developed historically and became authoritative for most Jewish communities.
Consequently, a program implementing the modern fixed calendar can calculate its dates reproducibly, but those calculations should not be assumed to reproduce every date observed in ancient history. Differences in sunset-based versus midnight-based day boundaries must also be considered when displaying dates for a particular location.
The purpose of this exercise is to explore a deterministic lunisolar calendar and the design of calendar-conversion algorithms, not to prescribe religious observance. A complete implementation requires careful treatment of epochs, integer arithmetic, the molad, and all postponement rules. Test cases should include ordinary years, leap years, and years of all six possible lengths.