1

Shalom, I am creating some pastoral care software for synagogues. One feature is the tracking of anniversary dates of life events - simchas, yahrzeits, etc. For this, I allow the user to set a reminder in advance of that date - 'Remind me x days before the anniversary date'. So, I may need to know the number of days in the previous month (or months). Eg. If the special event occurs 2nd Tishrei, and the reminder is 7 days before, I need to know first what month that would be (inc. accommodations for leap year Adar II) and how many days in the previous month.

Given that the number of days in several Hebrew months varies and with leap years, so does the number of months, I'm looking for a reliable mathematical way to programmatically calculate the number of days in the preceding month of that given Hebrew year.

Any help would be much appreciated.

  • 1
    This is a backwards way to do it, but couldn't you just convert the Jewish date to the secular one and program to remind "X days before on the secular calendar" which won't depend on the Jewish months. – rosends Aug 16 '19 at 16:05
  • Yes, and I'm leaning that way. But If there is a mathematical formula, it seems 'tighter'. I can't find out though. – Tremendus Apps Aug 16 '19 at 16:09
  • This doesn't answer the software question, but I just remember four rules: (1) Nissan has 30 (2) it alternates in a normal year (3) if it's a leap year, count backwards from Nissan for Adar 1 (4) Cheshvan and Kislev are sometimes wrong. Unfortunately, to deal with (4) you have to program in the whole calendar. – Heshy Aug 16 '19 at 16:25
  • Is the input just a Hebrew year number? If so there is no good way to calculate it directly. Any way you can prepopulate the dates of rosh hashana perhaps? Or can you get a package to covert Hebrew to Gregorian and count back from there? – Double AA Aug 16 '19 at 16:36
  • 1
    Thanks for the suggestions. I think I'll use Gregorian date libraries as follows: - convert anniversary to Greg. Subtract x days. Convert that date back to Hebrew. Should be good. – Tremendus Apps Aug 16 '19 at 17:04
  • 1
  • 1
    You might not need to reinvent the wheel. Take a look at https://www.hebcal.com/, they have an API, maybe you can use that. – Salmononius2 Aug 16 '19 at 19:26
  • We know of someone who was implementing direct support of the Hebrew calendar in a .NET library (https://judaism.stackexchange.com/q/39053/1713). Perhaps there are similar libraries in other programming languages as well, which would prevent you from even having to convert to Gregorian. – Daniel Aug 16 '19 at 20:02
  • @DonielF - this is not a duplicate. I'm not trying to convert dates. I'm trying to determine programmatically how many days are in a Hebrew month. The two needs are quite different - they are certainly different if you're a developer, I can assure you! – Tremendus Apps Aug 16 '19 at 22:01
  • @Salmononius2 Yes, I'm aware of Hebcal library but this is a heavy framework that contains 10s of thousands of lines of code that I don't want to include in my application because it has to be downloaded by every user. I was looking for a simple logical approach I could write in a function without heavy dependencies. Thanks for the suggestion though. – Tremendus Apps Aug 16 '19 at 22:02
  • @TremendusApps What about this question? – DonielF Aug 16 '19 at 22:02

1 Answers1

0

To somewhat condense some of the previous comments - As long as the anniversary as well as the # of days behind don't cross into either Cheshvan or Kislev, the month lengths are known and constant. Even Adar I and II have fixed lengths, and leap years occur during specific points in the 19 year cycle. As for Cheshvan and Kislev, you would have to know the starting dates of Rosh Hashanna for both the current and following years to determine the year length, and that will, in turn dictate the length of Cheshvan and Kislev.

That's not so simple as Rosh Hashannah's date starts with knowing the molad and then, there are 4 rules that could postpone that date by 1 or two days. Or, you can create a "lookup table" by entering the year and the "type of year" or year length, and use that. You can find that info online in various places.

Years ago, I wrote a Visual Basic program with Excel to calculate all this. If you're interested, inform me. I will warn that I won't have time to hunt for it for several weeks, though.

DanF
  • 70,416
  • 8
  • 59
  • 244