HijriDate
A Python package for accurate Hijri-Gregorian date conversion based on the Umm al-Qura calendar. It offers reliable date conversion, optimized performance, and multilingual support. The current version is 2.6.0 and it is actively maintained with a regular release cadence, including support for new Python versions.
Warnings
- breaking The package was renamed from `hijri-converter` to `hijridate` in version 2.3.0.
- breaking Support for Python 3.8 and 3.9 was dropped in `hijridate` v2.6.0. Python 3.7 support was dropped in v2.4.0, and Python 3.6 in v2.3.0.
- breaking The `validate` argument for `Hijri` and `Gregorian` object instantiation, and the `padding` argument for `dmyformat()` functions, became keyword-only arguments in v2.5.0.
- breaking The `slashformat()` method was removed from `Hijri` and `Gregorian` classes in v2.2.0.
- gotcha The converter supports dates only within the range 1343 AH to 1500 AH (1 August 1924 CE to 16 November 2077 CE) due to limitations of the official Umm al-Qura calendar sources. It is also not intended for religious purposes where lunar crescent sighting is preferred over astronomical calculations.
Install
-
pip install hijridate
Imports
- Hijri
from hijridate import Hijri
- Gregorian
from hijridate import Gregorian
Quickstart
from hijridate import Hijri, Gregorian
# Convert a Hijri date to Gregorian
hijri_date = Hijri(1445, 6, 15)
gregorian_date = hijri_date.to_gregorian()
print(f"Hijri {hijri_date} is Gregorian {gregorian_date}")
# Convert a Gregorian date to Hijri
gregorian_date = Gregorian(2023, 12, 28)
hijri_date_converted = gregorian_date.to_hijri()
print(f"Gregorian {gregorian_date} is Hijri {hijri_date_converted}")
# Get today's Hijri date
today_hijri = Hijri.today()
print(f"Today's Hijri date: {today_hijri}")