Skip to main content

A package for converting Hijriah Calendar Day

Project description

Hijriah Date Converter

Build Status PyPI - Python Version

A package to convert between Hijri and Gregorian calendar date using the Umm al-Qura calendar.

Installation

pip install hijri-calendar

Features

  • (Probably) 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(23, 3, 2021)
>>> print(gregorian.to_hijri())
'1455/8/1'

# getting hijri based month for both calendar
>>> example = Hijriah(21, 2, 2009).get_hijri_month()
>>> print(example)
'Safar'

# converting into ISO format
>>> example = Hijriah.to_representation(21, 2, 2009, "ISO")
>>> print(example)
'2009/21/2'

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.2.0.tar.gz (13.0 kB view hashes)

Uploaded Source

Built Distribution

hijri_calendar-0.2.0-py3-none-any.whl (11.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page