# Computer Programming/Hebrew calendar

**Programming a Hebrew calendar application**:

The intended audience for this summary of the mechanics of the Hebrew calendar is computer programmers who wish to design software that accurately computes dates in the Hebrew calendar. The following details may prove useful for validating such software. Note, however, that published Hebrew calendar algorithms are much simpler than the details listed below, and there is no need to employ tables in computer implementation of Hebrew calendar arithmetic. As usual, tables are useful shortcuts for humans carrying out the calculations manually.

- The Hebrew calendar is computed by lunations. One mean lunation is reckoned at 29 days, 12 hours, 44 minutes, 3⅓ seconds, or equivalently 765433 parts = 29 days, 13753 parts, where 1 minute = 18 parts (
*halakim*plural,*helek*singular). - A common year must be either 353, 354, or 355 days; a leap year must be 383, 384, or 385 days. A 353 or 383 day year is called
*haserah*. A 354 or 384 day year is*kesidrah*. A 355 or 385 day year is*shlemah*. - Leap years follow a 19 year schedule in which years 3, 6, 8, 11, 14, 17, and 19 are leap years. The Hebrew year 5758 (which starts in Gregorian year 1997) is the first year of a cycle.
- 19 years is the same as 235 lunations.
- The months are Tishrei, Cheshvan, Kislev, Tevet, Shevat, Adar, Nisan, Iyar, Sivan, Tammuz, Av, and Elul. In a leap year, Adar is replaced by Adar II (also called Adar Sheni or Veadar) and an extra month, Adar I (also called Adar Rishon), is inserted before Adar II.
- Each month has either 29 or 30 days. A 30 day month is full (מלא pronounced:
*maleh*,*maley*, or*malei*), whereas a 29 day month is defective (חסר pronounced:*ħaser*or*khaser*).- Nisan, Sivan, Av, Tishrei, and Shevat are always full.
- Iyar, Tammuz, Elul, Tevet, and Adar (Adar II in leap years) are always defective.
- Adar I, added in leap years before Adar II, is full.
- Cheshvan and Kislev vary. There are three possible combinations: both defective, both full, Cheshvan defective and Kislev full.

- Tishrei 1 (Rosh Hashana) is the day during which a
*molad*(instant of the mean lunar conjunction) occurs unless that conflicts with certain postponements (*dehiyyot*plural;*dehiyyah*singular). Note that for calendar computations, the Jewish date begins at 6 pm or six fixed hours before midnight when the date changes in the Gregorian calendar,*not*at nightfall or sunset when the observed Hebrew date begins.- Postponement A is required whenever Tishrei 10 (Yom Kippur) would fall on a Friday or a Sunday, or if Tishrei 21 (7th day of Sukkot) would fall on a Saturday. This is equivalent to the molad being on Sunday, Wednesday, or Friday. Whenever this happens, Tishrei 1 is delayed by one day.
- Postponement B is required whenever the molad occurs at or after noon. When this postponement exists, Tishrei 1 is delayed by one day. If this conflicts with postponement A then Tishrei 1 is delayed an additional day.
- Postponement C: If the year is to be a common year and the molad falls on a Tuesday at or after 3:11:20 am (3 hours 204 parts), Tishrei 1 is delayed by two days—if it weren't delayed, the resulting year would be 356 days long.
- Postponement D: If the new year follows a leap year and the molad is on a Monday at or after 9:32:43⅓ am (9 hours 589 parts), Tishrei 1 is delayed one day—if it weren't, the preceding year would have only 382 days.

- Postponements are implemented by adding a day to Kislev of the preceding year, making it full. If Kislev is already full, the day is added to Cheshvan of the preceding year, making it full also. If a delay of two days is called for, both Cheshvan and Kislev of the preceding year become full.
- A reference epoch in modern times is molad Tishrei for Hebrew year 5758, which is at 22:07:10 on Wednesday, 1 October 1997 (Gregorian), or equivalently midnight-referenced Julian day number 2450723 plus 23889 parts. This epoch also marks the beginning of a cycle. Note: Although the Julian day number begins at noon, it can be reckoned twelve hours earlier for programming purposes, which is what is meant here by the phrase, "midnight-referenced."

## Calculation by use of partial weeks[edit]

There are a number or approaches that can be taken in calculating Hebrew dates. One that is widely documented uses partial weeks and a table of limits. This method relies on all postponements being defined in terms of a seven-day week. That means that whole weeks between the epoch and the molad of the current year can be eliminated, leaving only a partial week with a few days, hours and parts.

- A nineteen-year cycle has 235 months of 29d 12h 793p each or 6939d 16h 595p. Eliminating 991 weeks leaves a partial week of 2d 16h 595p or 69715p.

- A common year has 12 months of 29d 12h 793p each or 354d 8h 876p. Eliminating 50 weeks leaves a partial week of 4d 8h 876p or 113196p.

- A leap year has 13 months of 29d 12h 793p or 383d 21h 589p. Eliminating 54 weeks leaves a partial week of 5d 21h 589p or 152869p.

Postponement B requiring a delay until the next day (beginning at 6 pm) if a molad occurs at or after noon effectively means that the week begins at noon Saturday for computational purposes.

Calculate the partial week between the molad of the desired Hebrew year and the preceding noon Saturday considering the partial week before molad Tishrei of AM 1 (or the first year of a more recent nineteen-year cycle) and the partial weeks from the intervening cycles and years within the current cycle, eliminating whole weeks via mod 181440, the number of parts in one week.

Thus molad Tishrei AM 1, which is 1d 5h 204p after 6 pm Saturday, is increased by 6 hours to 1d 11h 204p or 38004p. This is 5h 204p after the beginning (6 pm) of the second day of the week. In Western terms, this is 23:11:20 on Sunday (because it is before midnight), 6 October 3761 BCE in the proleptic Julian calendar. This date is midnight-referenced Julian day number 347997. Consulting the Table of Limits below, 1 Tishrei is the second day of the week, equivalent to the tabular Western day of Monday (same daylight period as the Hebrew day), which is 7 October 3761 BCE. This means no postponement was needed (both the molad Tishrei and 1 Tishrei were on the second day of the week).

Alternatively, the molad of a more recent Hebrew year may be selected as the epoch if it is the first year of a nineteen-year cycle, such as 5758 (used in rule 9), which is 303 nineteen-year cycles after molad Tishrei AM 1. Thus molad Tishrei 5758 is (38004 + 303×69715) mod 181440 = 114609 parts after noon Saturday, or 4d 10h 129p, which is 4h 129p after the beginning (6 pm) of the fifth day of the week. In Western terms, this is before midnight, which yields the date and time indicated in rule 9. Consulting the Table of Limits, 1 Tishrei is the fifth day of the week, or tabular Thursday 2 October 1997 (Gregorian), again no postponement was needed.

By applying the postponements to the moladot Tishrei at the beginning and end of any Hebrew year, a table of four gates (Hebrew: arba'ah sha'arim), which is also a table of limits, can be developed which uniquely identifies which of the fourteen types the year is (the day of the week of 1 Tishrei, the number of days in Cheshvan and Kislev, and whether common or leap (embolismic)).^{[1]}^{[2]}^{[3]}^{[4]} "Four gates" refers to the four allowable days of the week with which the year can begin. The first table of four gates was developed by Saadiah Gaon (892–942).^{[1]}^{[2]} In the following table, the years of a nineteen-year cycle are listed in the top row, organized into four groups: a common year after a leap year but before a common year (L**C**C, 1 4 9 12 15), a common year between two leap years (L**C**L, 7 18), a common year after a common year but before a leap year (C**C**L, 2 5 10 13 16), or a leap year between two common years (C**L**C, 3 6 8 11 14 17 19). The week since noon Saturday on the left is partitioned by a set of limits between which the molad Tishrei of the Hebrew year can be found. The resulting type of year in the body of the table indicates the day of the Hebrew week of 1 Tishrei (2, 3, 5, or 7), the four gates, and whether the year is deficient (−1), regular (0), or abundant (+1).

LCC1 4 9 12 15 |
LCL7 18 |
CCL2 5 10 13 16 |
CLC3 6 8 11 14 17 19 |
||

0 ≤ molad < | 16404 | 2 , −1 | |||

16404 ≤ molad < | 28571 | ||||

28571 ≤ molad < | 49189 | 2 , +1 | |||

49189 ≤ molad < | 51840 | ||||

51840 ≤ molad < | 68244 | 3 , 0 | |||

68244 ≤ molad < | 77760 | ||||

77760 ≤ molad < | 96815 | 5 , 0 | 5 , −1 | ||

96815 ≤ molad < | 120084 | ||||

120084 ≤ molad < | 129600 | 5 , +1 | |||

129600 ≤ molad < | 136488 | ||||

136488 ≤ molad < | 146004 | 7 , −1 | |||

146004 ≤ molad < | 158171 | ||||

158171 ≤ molad < | 181440 | 7 , +1 |

## References[edit]

- ↑
^{a}^{b}Bushwick, pp.95-97, Hebrew and English. Bushwick ignored 5, −1 for leap years. - ↑
^{a}^{b}Poznanski, p.121, Hebrew and English. Poznanski ignored 5, −1 for leap years in his table although he lists it in his text. - ↑ Resnikoff, p.276, English. Resnikoff is correct.
- ↑ The four gates can be presented in many ways. Resnikoff only used parts (up to 181440) whereas Bushwick and Poznanski used days, hours, and parts. Bushwick began the week at noon Saturday whereas Resnikoff and Poznanski began their week at 6 pm Saturday. Bushwick and Poznanski had cyclic years on the left and types of years on top. Resnikoff rotated his table 90° to the right, so cyclic years were on top and types of years on the right, similar to the table given here.