Pyluach: Hebrew (Jewish) Calendar Dates
Pyluach is a Python package designed for manipulating Hebrew (Jewish) calendar dates. It provides functionalities for converting between Hebrew and Gregorian dates, calculating date differences, finding weekdays, identifying weekly Torah readings (Parshios), and determining holidays. The library is actively maintained, with version 2.3.0 being the current stable release, and new minor versions released periodically.
Warnings
- gotcha The `holiday()` method (e.g., `HebrewDate.holiday()`) includes all major, minor, and fast days, whereas the `festival()` method (e.g., `HebrewDate.festival()` or `hebrewcal.festival()`) explicitly *excludes* fast days and often includes other working festival days (Chol Hamoed etc.). Using the wrong method can lead to unexpected holiday lists.
- gotcha Pyluach's `JulianDay` object, while representing a Julian day number, treats the day transition at midnight (like conventional dates) rather than the astronomical convention of noon. This can lead to off-by-one errors for users expecting traditional astronomical Julian Day behavior around midday.
- gotcha Hebrew month numbering in `pyluach`, especially when instantiating `HebrewDate` or `hebrewcal.Month`, follows a non-sequential order: Tishrei (7) through Adar Sheni (13, if applicable for a leap year), then Nissan (1) through Elul (6). This differs from a simple 1-12 or 1-13 enumeration and can be a source of `ValueError` if incorrect month numbers are used.
Install
-
pip install pyluach
Imports
- dates
from pyluach import dates
- hebrewcal
from pyluach import hebrewcal
- parshios
from pyluach import parshios
- HebrewDate
from pyluach.dates import HebrewDate
- GregorianDate
from pyluach.dates import GregorianDate
Quickstart
from pyluach import dates, hebrewcal, parshios
# Get today's Hebrew date
today = dates.HebrewDate.today()
print(f"Today's Hebrew date: {today.hebrew_date_string(hebrew=True)}")
print(f"Today's Gregorian equivalent: {today.to_greg()}")
# Convert between Gregorian and Hebrew dates
greg_date = dates.GregorianDate(1986, 3, 21)
heb_date = greg_date.to_heb()
print(f"Gregorian {greg_date} is Hebrew {heb_date}")
# Check for holidays and parsha
rosh_hashana = dates.HebrewDate(5782, 7, 1)
print(f"Holiday on Rosh Hashana 5782: {rosh_hashana.holiday()}")
# Get weekly Torah portion
parsha_date = dates.GregorianDate(2021, 3, 10)
print(f"Parsha for {parsha_date}: {parshios.getparsha_string(parsha_date)}")