Skip to main content

A Python package for handling Hebrew dates

Project description

hebrewdate

A comprehensive Python library for working with the Hebrew calendar, providing date conversions, calendar generation, and holiday information.

It offers four main classes:

  • HebrewDate: Represents a specific date in the Hebrew calendar, with support for conversions to/from Gregorian dates, manipulation of dates (e.g., adding or subtracting days, months, or years), and various date-related attributes such as day, month, year, and weekday in the Hebrew calendar.
  • HebrewYear: Represents a Hebrew year, managing leap year calculations, month lengths, and determining the first weekday of the year.
  • HebrewCalendar: Extends Python's built-in Calendar class to provide Hebrew calendar functionality, including methods for iterating over month days and converting between Hebrew and Gregorian dates.
  • HTMLHebrewCalendar: Provides HTML formatting of Hebrew calendar data with support for both Hebrew and Gregorian date display, selection layers for holidays, festive days, and fasts, custom CSS styling.

Key Features:

  • Conversion between Hebrew and Gregorian dates.
  • Support for Hebrew holidays, festive days, and fasts.
  • Computation of weekdays, month lengths, and leap years for Hebrew dates.
  • Operations for date arithmetic, such as adding and subtracting days, months, and years.
  • Methods for getting today's Hebrew date or constructing a Hebrew date from a Gregorian date.
  • Calendar iteration and formatting for Hebrew dates in HTML format.
  • Generate HTML calendars with customizable styling.
  • Support for generating complete calendar pages for months and years.

Limitations:

  • Supported Python versions: 3.9 and later
  • Date conversions before 1752 CE may be inaccurate due to historical and calendar system variations.
  • Dates far in the past may not be convertible to Gregorian dates

Installation

pip install hebrewdate

Usage

>>> from hebrewdate import HebrewDate, HTMLHebrewCalendar
# Get today's Hebrew date
>>> today = HebrewDate.today()
>>> print(today)
e.g. יום ראשון א ניסן ה'תשפ"ה
# Convert to Gregorian
>>> print(today.to_gregorian())
e.g. 2025-03-30

# Convert from Gregorian to Hebrew
>>> h = HebrewDate.from_gregorian(13, 4, 2025)
# Check holiday
>>> if h.is_holiday:
...     print(pesach.holiday)
...
יו"ט ראשון של פסח

# Generate an HTML calendar
cal = HTMLHebrewCalendar(with_gregorian=False)
html = cal.formatmonth(5785, 1) # תשרי ה'תשפ"ה

Contribution

Contributions are welcome! Feel free to submit a Pull Request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Author

Isaac Dovolsky © 2025

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hebrewdate-2.0.1.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hebrewdate-2.0.1-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file hebrewdate-2.0.1.tar.gz.

File metadata

  • Download URL: hebrewdate-2.0.1.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for hebrewdate-2.0.1.tar.gz
Algorithm Hash digest
SHA256 79ba065f087e58abaa11b9b7d454f060b53f4caf5608432b9a0be5ab92438326
MD5 315ddf9f836a79df27db054c8df4c410
BLAKE2b-256 db9b90b62a22f2a7b3d6d48aa1924fe24e900779a5a68a004849da1f277fc2c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for hebrewdate-2.0.1.tar.gz:

Publisher: python-publish.yml on Isaac-D20/hebrewdate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hebrewdate-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: hebrewdate-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for hebrewdate-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d56d9af3d5a064d1c8c8cd06fdbe85f85731c48417dfef622b3093feb6dc9d94
MD5 862bf0c8d266c6a021b3b8229a519fdf
BLAKE2b-256 2565535696fc65384f1b4db2fb9049c78d88a9d9f674fb85c22fef43346628b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for hebrewdate-2.0.1-py3-none-any.whl:

Publisher: python-publish.yml on Isaac-D20/hebrewdate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page