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

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.1.0.tar.gz (17.1 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.1.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for hebrewdate-2.1.0.tar.gz
Algorithm Hash digest
SHA256 d55e0e4397bc415a35f44d8184bb1814b67e105829b17e0080d582065ef9dc76
MD5 f116f325928b66da7cbce4533964a460
BLAKE2b-256 a4e16957585c79a116ede25ae8ef460e73234cc1dd13cc14c90dd3f15f3cde2a

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: hebrewdate-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.5 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a951343bb8b61f640072bc704c3b14565d5c1bfa100f4153a1e168e0d7e99f5
MD5 191fedf2ddbf26e49276d9b4537f5108
BLAKE2b-256 5be34154a88bad46181813fdb461f83058640bc03a5b551634bbc1440c30e0cd

See more details on using hashes here.

Provenance

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