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/1447'

# 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)
'Safar'

# 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.4.0.tar.gz (15.0 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.4.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hijri_calendar-0.4.0.tar.gz
  • Upload date:
  • Size: 15.0 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.4.0.tar.gz
Algorithm Hash digest
SHA256 ec0a4cb52883d88f83464f85ce5c2f10f52e8ec0003c768a5f9c17e2ec09fdec
MD5 f694f2fd69d99d6e7d4b509a043590ce
BLAKE2b-256 561249bd4520901c3735a9d3b4a74cff2eaa42b7cffa7c463a9f409515ad5730

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hijri_calendar-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4b5afea50bdff74e6aedc8f86b894e04a44ef20c23f582e3221554f0a3fe8ca
MD5 98ae9392ba38072fa589b7a401c8118c
BLAKE2b-256 223f356f0b76d0033a3ae675ee5c1de13fb4a8c45aef0286312e8107fbf83d15

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