FAQ: How do I Calculate the Jewish/Hebrew Date for …?

Java Calendar

This FAQ is now obsolete. Jewish Calendar Calculations are now supported. See the Zmanim API 1.3.0 Release announcement

Question:

How do I get the Jewish Date for … using the Zmanim API?

Answer:

The current version of the Zanim API does not support Jewish calendrical calculations. Zmanim are almost exclusively based on the solar calendar, so for example, the sunrise on February 8th this year in Montreal (or any other date and location), will be almost the same every year. for this reason there was little point (as far as zmanim) to support Jewish date calculations in the API. One of the only zmanim to rely on a Jewish date is the sof zman kidush levanah calculation, though there are some opinions that it is purely molad based, and this can be calculated without a Jewish calendar component to the API. This zman is obviously not currently implemented in the Zmanim API. I am currently working on adding Jewish date support to the API. The code is based off Avrom Finkelstein‘s no longer active HebrewDate project. I refactored a lot of the code and fixed a number of bugs. Anyone interested in alpha testing this code can download the latest Zmanim SVN code (or download the Zmanim API 1.3.0 alpha release).
I mentioned that it “will be almost the same every year” and this is due the the approximate 1/4 day drift between the 356 day calendar year and the approximately 365.25 days actually present in the astronomical year, a discrepancy corrected every leap year. A future FAQ (probably a few of them) may delve specifically into this drift as well as general zmanim accuracy issues in detail.
If you are simply looking to convert a Hebrew date to Gregorian or Gregorian to Hebrew online without the API, try the JewishGen calendar conversion tools.

12 thoughts on “FAQ: How do I Calculate the Jewish/Hebrew Date for …?”

    1. Avraham,
      Thank you for your interest. I updated the post above to include a link to the Zmanim API alpha 1 release that includes the calendar code. It is still under very heavy development. You can expect significant changes (that may break your code on an update) over the next few months. Please review the code and provide your comments here. There is currently no Rosh Chodesh support, but it will return yomim tovim.

    2. RoshChodesh is as simple as the code below and I plan on adding it to the API. It also currently returns the day of the Omer (and an Integer.MIN_VALUE if it is not in the Omer).

      public boolean isRoshChodesh(){
          //Rosh Hashana is not rosh chodesh and Elul never has 30 days
          return (jewishDay==1 && jewishMonth != 7) || jewishDay==30;
      }
      1. Thanks for the code.
        I already implemented similar code in my apps before, but as the Hebrew date algorithm I’m currently using is heavily depended on the Gregorian calendar, I had to make it more accurate for “Erev Rosh Chodesh”/”Erev Hannuka” – as for Arvit time before that date, the date is 28/29 but the Hebrew date actually became 30/1. So now each time I need to know if isRoshChodesh() I need to check tomorrow’s date as well, and split a single query into two – according to the time of day – isRoshChodesh() and isErevRoshChodesh(), etc.

        As for some other yomim tovim, it becomes more complicated as for calculating Hannuka you need to check if it’s ended in 2 or 3 in Tevet as well, which is something you can do using the Gauss calculation, but it’s not so elegant (checking if 2/3 days ago the date was 29/30).

        Now, as you developing this great addition to your API, it would be nice if this calculation will be done within the API code, and querying isRoshChodesh() will return the accurate answer for Erev Rosh Chodesh and will know to return false for Arvit time of the 1 day in month, and so on. I hope I made myself clear now.

        Regards,
        Avraham

        1. Avraham,
          At this point I do not plan on adding a time concept to the class, so in checking after Tzais you will have to query the next date. Also, since isRoshChodesh() returns a boolean, I can’t have it return true for erev rosh chodesh. Please let me know of any suggestions that you have.

          Now, as you developing this great addition to your API, it would be nice if this calculation will be done within the API code, and querying isRoshChodesh() will return the accurate answer for Erev Rosh Chodesh and will know to return false for Arvit time of the 1 day in month, and so on. I hope I made myself clear now.

Leave a Reply

Your email address will not be published. Required fields are marked *