Skip to main content

A package for converting Hijriah Calendar Day

Project description

Hijriah Date Converter

PyPI Downloads codecov

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 inputted the gregorian or hijri version of the calendar with something like:

from hijri.core import Hijriah

# convert gregorian calendary day into hijriah
>>> gregorian = Hijriah(day=21, month=12, year=2025)
>>> print(gregorian.to_hijri())
'1/7/1460'

# getting hijri month based on the gregorian calendar
>>> gregorian = Hijriah(day=21, month=12, year=2025)
>>> get_month = gregorian.get_hijri_month()
>>> print(get_month)
'Dzul Hijjah'

# converting into common ISO format
>>> get_iso = Hijriah.to_representation(day=21, month=12, year=2024, date_format="ISO")
>>> print(get_iso)
'21/12/21'

# converting into more standard version of ISO
>>> get_iso = Hijriah.to_representation(day=21, month=12, year=2024, date_format="ISO-8601")
>>> print(get_iso)
'2024-12-21'

For further usage, please refer 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 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 Hijriah calendar is difficult to predict / compute. For example, bad weather conditions may delay the beginning of a new month by one day at short notice.

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

hijri_calendar-0.3.0.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

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

hijri_calendar-0.3.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file hijri_calendar-0.3.0.tar.gz.

File metadata

  • Download URL: hijri_calendar-0.3.0.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for hijri_calendar-0.3.0.tar.gz
Algorithm Hash digest
SHA256 aa9c81a8d0bbdbc7d475463f2ff6e1b9e1562c7cd5b6337eb8c9ed2b3d81d1d3
MD5 30eb7e0562bbe17610591ced2e2eafe2
BLAKE2b-256 e7d82846d480c7a28dea0f835a055b7000c945f556a6a90f5901deafedd52c42

See more details on using hashes here.

File details

Details for the file hijri_calendar-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: hijri_calendar-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for hijri_calendar-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e176fe2e77df9bcc1d7ce72d666d4aa83c9769438426fdf1fdf7a8d9f0cb631
MD5 ff2e0196d347bfc78870d5837784b016
BLAKE2b-256 ce73e299e67a9639e1f074cc0ce47edb7cad3768aba14adaf5e9121694c1d6f1

See more details on using hashes here.

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