Hijriah Date Converter
A package to convert between Hijri and Gregorian calendar date using the Umm al-Qura calendar.
Installation
pip install hijri-calendar
Features
- Supported ISO and another extendable date format
- Representation to string with formatted name of the month based on hijriah calendar
- Offset and limit range for both calendar
Usage
The usage itself is quite straightforward, just input the gregorian or hijri version of the calendar with something like:
from hijri.core import Hijriah
# convert gregorian calendar day into hijriah
>>> gregorian = Hijriah(day=21, month=12, year=2025)
>>> print(gregorian.to_hijri())
1/7/1447
# get the hijri month name from the month number
>>> hijri = Hijriah(day=21, month=12, year=2025)
>>> print(hijri.get_hijri_month())
Dzul Hijjah
# convert hijri calendar day into gregorian
>>> hijri = Hijriah(day=8, month=2, year=1434)
>>> print(hijri.to_gregorian())
21/12/2012
# convert into standard ISO date format (returns Hijriah object)
>>> get_iso = Hijriah.to_representation(day=21, month=12, year=2024, date_format="ISO")
>>> print(get_iso)
21/12/2024
# convert into ISO-8601 string format
>>> get_iso = Hijriah.to_representation(day=21, month=12, year=2024, date_format="ISO-8601")
>>> print(get_iso)
2024-12-21
# convert into DMY format (returns Hijriah object)
>>> get_dmy = Hijriah.to_representation(day=11, month=9, year=2025, date_format="DMY")
>>> print(get_dmy)
11/9/2025
For further usage, please refer to the example.py file
Acknowledgment
For the calculation formula itself i adopted from several resources and packages, especially with these two, Python Islamic Library and Hijri.js
Caveats
For accuracy itself, to be honest i don't really know how accurate it is for calendar conversion. For example, if we inputted the current date (from 2021), the conversion result to the hijri year is 1455 which is actually wrong. After some research, there is a leap day in the Hijri calendar which will increase every 2 or 3 years and there are also 11 leap years in a 30-year cycle. Their distribution varies slightly from one country or Muslim community to another.
In addition to the leap days that are inserted in solar calendars like the Gregorian calendar or Julien Calendar, the Hijriah leap day is not designed to align the calendar with the solar year, which on average lasts just over 365 days.
Furthermore, this makes the calculation of the months in the Hijriah calendar difficult to predict. For example, bad weather conditions may delay the beginning of a new month by one day at short notice.
Metadata
Release files for hijri-calendar 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hijri_calendar-0.6.0.tar.gz | 17.5 kB | Without provenance | Details for hijri_calendar-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hijri_calendar-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for hijri_calendar-0.6.0-py3-none-any.whl |
Total release size: 30.9 kB
Release files / hijri_calendar-0.6.0.tar.gz
| Download URL | hijri_calendar-0.6.0.tar.gz |
|---|---|
| Size | 17.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0bfead026c1443fd87fc96d8a28262a9df94b85f838cb3c14baa43afc92e174c
|
|
BLAKE2b-256 checksum How to use checksums |
413adf8205c5bdefa776718f65494fe08a19f92f8d8aba1eaf75b684e8c9cdd5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / hijri_calendar-0.6.0-py3-none-any.whl
| Download URL | hijri_calendar-0.6.0-py3-none-any.whl |
|---|---|
| Size | 13.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
571c51adb310cfcc15e69ecf61d77ffbf98ace4fd81394e891d53a121569c986
|
|
BLAKE2b-256 checksum How to use checksums |
cdf1eb1ae64c23b9507cb32324b7f5e77e9ec9ba2ed82204bc4a8f80791598d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for hijri-calendar 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.