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, and 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.4.tar.gz (16.5 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.4-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hebrewdate-2.0.4.tar.gz
  • Upload date:
  • Size: 16.5 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.4.tar.gz
Algorithm Hash digest
SHA256 f742e32fd0c1970a2fa3c3eef2660d87b6d00a06e719ca9f01c4bde1c3ec452d
MD5 99b124947c58c76e24c82f8814926bfc
BLAKE2b-256 abd6298addc76121e925cec1c162a15e4375046af5e55cccb01e7dab11e178f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for hebrewdate-2.0.4.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.4-py3-none-any.whl.

File metadata

  • Download URL: hebrewdate-2.0.4-py3-none-any.whl
  • Upload date:
  • Size: 13.2 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2053c9f2c650317f067e0cac6afe700aeabe100a3000a8f156ad183c7bdf8da0
MD5 cc392075e49f9cf6eac43fd85f22b1f7
BLAKE2b-256 906eef95f5fc3e82672438f7ca6b9ba1ce614cb267d1809740f78787a6734e13

See more details on using hashes here.

Provenance

The following attestation bundles were made for hebrewdate-2.0.4-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