adhanpy
This is a port of batoulapps/adhan-java, a prayer times program, from Java to Python. As it stands the project reuses most of the structure of the original project but may differ through refactoring and in an effort to rewrite in a more pythonic way where it makes sense. Like the original project there are no external dependencies except in development where pytest and other development tools are made use of.
Requirements
- Python >= 3.9
Installation
pip install adhanpy
Usage
Create a PrayerTimes object by passing geo coodinates, datetime and either passing a calculation method:
prayer_times = PrayerTimes(coordinates, today, CalculationMethod.MOON_SIGHTING_COMMITTEE)
or a calculation parameters object allowing to choose from different parameters such as angles:
parameters = CalculationParameters(fajr_angle=18, isha_angle=18)
prayer_times = PrayerTimes(coordinates, today, calculation_parameters=parameters)
If passing a calculation method to the calculation parameters object, the calculation method will have precedence and will overwrite other parameters you may have also passed.
For instance the MOON_SIGHTING_COMMITTEE method uses a fajr angle of 18 and if for instance the calculation parameters object is created by passing a different fajr angle the latter will be ignored:
parameters = CalculationParameters(fajr_angle=12, method=CalculationMethod.MOON_SIGHTING_COMMITTEE)
prayer_times = PrayerTimes(coordinates, today, calculation_parameters=parameters)
print(parameters.fajr_angle)
# 18.0 (the fajr_angle argument has been ignored)
Times are returned in UTC time via datetime objects, for convenience it is possible to directly pass a ZoneInfo object to PrayerTimes:
london_zone = ZoneInfo("Europe/London")
prayer_times = PrayerTimes(
coordinates,
today,
CalculationMethod.MOON_SIGHTING_COMMITTEE,
time_zone=london_zone,
)
# this will display the time in the chosen time zone
print(f"Fajr: {prayer_times.fajr.strftime('%H:%M')}")
or convert to a different timezone later, each prayer time object is in fact a datetime object:
prayer_times = PrayerTimes(
coordinates,
today,
CalculationMethod.MOON_SIGHTING_COMMITTEE,
)
# the following will be in UTC
print(f"Fajr: {prayer_times.fajr.strftime('%H:%M')}")
# and to use a different timezone on the datetime object itself:
london_zone = ZoneInfo("Europe/London")
print(f"Fajr: {prayer_times.fajr.astimezone(london_zone).strftime('%H:%M')}")
A full example is located in src/example of the project directory.
Development
To install adhanpy for development purposes, run the following:
python3 -m virtualenv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
Licence
MIT
Acknowledgments
Credits go to the author of the original implementation in Java and other languages, especially the very complex astronomy formulas.
Metadata
Release files for adhanpy 1.0.5
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 |
|---|---|---|---|---|
| adhanpy-1.0.5.tar.gz | 13.7 kB | Without provenance | Details for adhanpy-1.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| adhanpy-1.0.5-py3-none-any.whl | Python 3 | none | any | Details for adhanpy-1.0.5-py3-none-any.whl |
Total release size: 30.9 kB
Release files / adhanpy-1.0.5.tar.gz
| Download URL | adhanpy-1.0.5.tar.gz |
|---|---|
| Size | 13.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9b6670f8d563d61d4f9fde581165cbe692c917710b694cb6b5e2130ffc902680
|
|
BLAKE2b-256 checksum How to use checksums |
82771111dd754493146e14d4a28ac4df114cc5c74b4317055a300dd5df3df1bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / adhanpy-1.0.5-py3-none-any.whl
| Download URL | adhanpy-1.0.5-py3-none-any.whl |
|---|---|
| Size | 17.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
79d765e6b91d3b29448988691957b51109faaca10f498eb3656e7c87b56b6066
|
|
BLAKE2b-256 checksum How to use checksums |
365b89b9705b95aca620409574ce4bd4e013c33d3fd1f27edf7ab9b9ca40a18c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Security for adhanpy 1.0.5
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.