# hebrewcal module

The hebrewcal module implements classes for representing a Hebrew year and month.

It also has functions for getting the holiday or fast day for a given date.

pyluach.hebrewcal.fast_day(date, hebrew=False)

  Return name of fast day or None.

  Parameters

    - date (`HebrewDate`, `GregorianDate`, or `JulianDay`) – Any date that implements a `to_heb()` method which returns a `HebrewDate` can be used.

    - hebrew (bool, optional) – `True` if you want the fast_day name in Hebrew letters. Default is `False`, which returns the name transliterated into English.

  Returns

    The name of the fast day or `None` if the given date is not a fast day.

  Return type

    str or `None`

pyluach.hebrewcal.festival(date, israel=False, hebrew=False)

  Return Jewish festival of given day.

  This method will return all major and minor religous Jewish holidays not including fast days.

  Parameters

    - date (`HebrewDate`, `GregorianDate`, or `JulianDay`) – Any date that implements a `to_heb()` method which returns a `HebrewDate` can be used.

    - israel (bool, optional) – `True` if you want the festivals according to the Israel schedule. Defaults to `False`.

    - hebrew (bool, optional) – `True` if you want the festival name in Hebrew letters. Default is `False`, which returns the name transliterated into English.

  Returns

    The name of the festival or `None` if the given date is not a Jewish festival.

  Return type

    str or `None`

pyluach.hebrewcal.holiday(date, israel=False, hebrew=False)

  Return Jewish holiday of given date.

  The holidays include the major and minor religious Jewish holidays including fast days.

  Parameters

    - date (`HebrewDate`, `GregorianDate`, or `JulianDay`) – Any date that implements a `to_heb()` method which returns a `HebrewDate` can be used.

    - israel (bool, optional) – `True` if you want the holidays according to the israel schedule. Defaults to `False`.

    - hebrew (bool, optional) – `True` if you want the holiday name in Hebrew letters. Default is `False`, which returns the name transliterated into English.

  Returns

    The name of the holiday or `None` if the given date is not a Jewish holiday.

  Return type

    str or `None`

class pyluach.hebrewcal.Year(year)

  Bases: `object`

  A Year object represents a Hebrew calendar year.

  It provided the following operators:

  Operation | Result
  --- | ---
  year2 = year1 + int | New `Year` `int` days after year1.
  year2 = year1 - int | New `Year` `int` days before year1.
  int = year1 - year2 | `int` equal to the absolute value of the difference between year2 and year1.
  bool = year1 == year2 | True if year1 represents the same year as year2.
  bool = year1 > year2 | True if year1 is later than year2.
  bool = year1 >= year2 | True if year1 is later or equal to year2.
  bool = year1 < year2 | True if year 1 earlier than year2.
  bool = year1 <= year2 | True if year 1 earlier or equal to year 2.

  Parameters

    year (int) – A Hebrew year.

  year

    The hebrew year.

    Type

      int

  leap

    True if the year is a leap year else false.

    Type

      bool

  itermonths()

    Yield Month instance for each month of the year.

    Yields

      `Month` – The next month in the Hebrew calendar year as a `luachcal.hebrewcal.Month` instance beginning with Tishrei and ending with Elul.

  iterdays()

    Yield integer for each day of the year.

    Yields

      int – An integer beginning with 1 representing the next day of the year.

  iterdates()

    Yield HebrewDate instance for each day of the year.

    Yields

      HebrewDate – The next date of the Hebrew calendar year starting with the first of Tishrei.

  classmethod from_date(date)

    Return Year object that given date occurs in.

    Parameters

      date (`HebrewDate`, `GregorianDate`, or `JulianDay`) – Any one of the `pyluach` date types.

    Returns

    Return type

      Year

  classmethod from_pydate(pydate)

    Return Year object from python date object.

    Parameters

      pydate (`datetime.date`) – A python standard library date object

    Returns

      The Hebrew year the given date occurs in

    Return type

      Year

  year_string(thousands=False)

    Return year as a Hebrew string.

    Parameters

      thousands (bool, optional) – `True` to prefix the year with the thousands place. default is `False`.

    Examples

        >>> year = Year(5781)
        >>> year.year_string()
        תשפ״א
        >>> year.year_string(True)
        ה׳תשפ״א

class pyluach.hebrewcal.Month(year, month)

  Bases: `object`

  A Month object represents a month of the Hebrew calendar.

  It provides the same operators as a Year object.

  Parameters

    - year (int) –

    - month (int) – The month as an integer starting with 7 for Tishrei through 13 if necessary for Adar Sheni and then 1-6 for Nissan - Elul.

  year

    The Hebrew year.

    Type

      int

  month

    The month as an integer starting with 7 for Tishrei through 13 if necessary for Adar Sheni and then 1-6 for Nissan - Elul.

    Type

      int

  name

    The name of the month.

    Deprecated since version 1.3.0: name attribute will be removed in pyluach 2.0.0, it is replaced by month_name method, because the latter allows a hebrew parameter. The month_name also uses slightly different transliteration.

    Type

      str

  classmethod from_date(date)

    Return Month object that given date occurs in.

    Parameters

      date (`HebrewDate`, `GregorianDate`, or `JulianDay`) – Any `pyluach` date type

    Returns

      The Hebrew month the given date occurs in

    Return type

      Month

  classmethod from_pydate(pydate)

    Return Month object from python date object.

    Parameters

      pydate (`datetime.date`) – A python standard library date object

    Returns

      The Hebrew month the given date occurs in

    Return type

      Month

  month_name(hebrew=False)

    Return the name of the month.

    Replaces name attribute.

    Parameters

      hebrew (bool, optional) – True if the month name should be written with Hebrew letters and False to be transliterated into English using the Ashkenazic pronunciation. Default is False.

    Returns

    Return type

      str

  month_string(thousands=False)

    Return month and year in Hebrew.

    Parameters

      thousands (bool, optional) – `True` to prefix year with thousands place. Default is `False`.

    Returns

      The month and year in Hebrew in the form `f'{month} {year}'`.

    Return type

      str

  starting_weekday()

    Return first weekday of the month.

    Returns

      The weekday of the first day of the month starting with Sunday as 1 through Saturday as 7.

    Return type

      int

  iterdates()

    Return iterator that yields an instance of HebrewDate.

    Yields

      `HebrewDate` – The next Hebrew Date of the year starting the first day of Tishrei through the last day of Ellul.

  molad()

    Return the month’s molad.

    Returns

      A dictionary in the form {weekday: int, hours: int, parts: int}

    Return type

      dict

    Note

    This method does not return the molad in the form that is traditionally announced in the shul. This is the molad in the form used to calculate the length of the year.

    See also

    `molad_announcement`

      The molad as it is traditionally announced.

  molad_announcement()

    Return the months molad in the announcement form.

    Returns a dictionary in the form that the molad is traditionally announced. The weekday is adjusted to change at midnight and the hour of the day and minutes are given as traditionally announced. Note that the hour is given as in a twenty four hour clock ie. 0 for 12:00 AM through 23 for 11:00 PM.

    Returns

      A dictionary in the form:

          {
              weekday: int,
              hour: int,
              minutes: int,
              parts: int
          }

    Return type

      dict