Accurate Hijri-Gregorian date converter based on the Umm al-Qura calendar
Project description
A Python package to convert accurately between Hijri and Gregorian dates using the Umm al-Qura calendar of Saudi Arabia.
Overview
The Umm al-Qura calendar is the lunar Hijri (Islamic) calendar officially adopted by Saudi Arabia for administrative purposes. It is mainly used by the government, including its health care and education systems, in which almost all documents and transactions are dated by the Hijri calendar.
However, the Gregorian calendar is the calendar used in most of the world, and it has been implemented as the default calendar in nearly every computer and database.
Therefore, a valid converter between Hijri and Gregorian dates is a necessity, especially when conducting research, analyzing data, or building applications that may have Hijri dates. Even though similar packages exist and try to fill the gap, Hijri Converter comes with a pythonic code, more accuracy, and better performance.
Features
Accurate and reliable conversion.
Complete alignment with the official calendar.
Optimized code performance compared to similar packages.
Intuitive, clean, and easy-to-use interface.
Most of methods and formats are similar to those of standard library.
Multilingual representation of weekday names, months, and calendar notations.
Easily extendable to support other natural languages.
Rich comparison between dates.
Validation of input dates.
Works on Python 3.6+ with zero dependencies.
Thoroughly tested on all supported python versions.
Online Demo
The following website implements a simple conversion tool using this package:
Installation
$ pip install -U hijri-converter
Basic Usage
from hijri_converter import convert
g = convert.Hijri(1403, 2, 17).to_gregorian()
print(g)
# 1982-12-02
h = convert.Gregorian(1982, 12, 2).to_hijri()
print(h)
# 1403-02-17
Documentation
Please see https://hijri-converter.readthedocs.io/ for full documentation of this package, including benchmarking, usage examples and API reference.
Contributing
Contributions are welcome! See CONTRIBUTING.rst for more info.
Acknowledgment
Thanks to R.H. van Gent for inspiration and help.
License
This package is distributed under an MIT license. See LICENSE.
Change Log
2.0.0
In short, this version supports only lunar Hijri calendar on Python 3.6+ with a more accurate conversion in complete alignment with the Umm al-Qura official calendar.
Details are as follows:
Renamed the package to hijri-converter.
Dropped support for the solar Hijri calendar.
Dropped support for Python 3.5.
Refactored localization and ummalqura.py module.
Updated month_starts tuple to make the conversion more accurate.
Added fromdate() classmethod to Gregorian object.
Added notation() method to Hijri and Gregorian objects.
Added more methods to Gregorian object including slashformat(), month_name(), day_name() and to_julian().
Renamed month_days() method of Hijri object to month_length().
Changed formatted string to use f-strings.
Improved documentation and examples.
Updated unit tests.
Fixed other minor issues and typos.
1.5.0
Added fromisoformat() classmethod to Hijri object.
Added support for rich comparison between Hijri dates.
Updated documentation and testing code.
Other minor fixes and enhancements.
1.4.0
Refactored conversion methods to improve performance.
Changed date validation back to be the default and removed optional parameter.
Added to_julian() method to Hijri object.
Updated documentation and testing code.
Other minor fixes and enhancements.
1.3.3
Fixed a bug in range validation for the Gregorian date.
Changed generic typing to built-in types.
Added more tests to cover the solar calendar.
Improved code structure and documentation.
1.3.2
Improved documentation and changelog.
1.3.1
Fixed README file.
1.3.0
Added documentation directory with an online version.
Changed date input validation to be optional and disabled by default.
Improved code readability and performance.
Other minor fixes and enhancements.
1.2.0
Added slashformat() method to Hijri object.
Improved date validation code.
Fixed some typos in documentation and docstrings.
1.0.1
Improved examples and documentation.
1.0.0
First release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file hijri-converter-2.0.0.tar.gz
.
File metadata
- Download URL: hijri-converter-2.0.0.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e619e905d621efe9250360ca792994dab97bf786ae475209a00aefac39988236 |
|
MD5 | 202b78182cbb4d265e1d07bc01a60ee4 |
|
BLAKE2b-256 | 37bcce93cd74c599f3fd176086d2e6364fdcb9022c9d5ba27e6ac0fa3ff7a8cb |
File details
Details for the file hijri_converter-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: hijri_converter-2.0.0-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3608f5c5eb46e25779b12f5040bd4562978c9c4e6bf46fb1fa67b43807219e2 |
|
MD5 | 433f4e921439e57922730c1eb646f7a2 |
|
BLAKE2b-256 | 3fed51f41ba98471727ce45e593e9061a75f8227f15b52a544bd1e8d682e6df7 |