adhanpy


Nameadhanpy JSON
Version 1.0.5 PyPI version JSON
download
home_pagehttps://github.com/alphahm/adhanpy
SummaryAn offline library calculating prayer times
upload_time2023-01-28 15:54:32
maintainer
docs_urlNone
authoralphahm
requires_python
license
keywords
VCS
bugtrack_url
requirements black pytest pytest-cov pytest-mock
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # adhanpy

[![License: MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
![pytest](https://github.com/alphahm/adhanpy/actions/workflows/test.yml/badge.svg)

This is a port of [batoulapps/adhan-java](https://github.com/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](https://github.com/pytest-dev/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:

```python
prayer_times = PrayerTimes(coordinates, today, CalculationMethod.MOON_SIGHTING_COMMITTEE)
```

or a calculation parameters object allowing to choose from different parameters such as angles:

```python
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:

```python
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:

```python
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:

```python
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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/alphahm/adhanpy",
    "name": "adhanpy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "alphahm",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/82/77/1111dd754493146e14d4a28ac4df114cc5c74b4317055a300dd5df3df1bf/adhanpy-1.0.5.tar.gz",
    "platform": null,
    "description": "# adhanpy\n\n[![License: MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)\n![pytest](https://github.com/alphahm/adhanpy/actions/workflows/test.yml/badge.svg)\n\nThis is a port of [batoulapps/adhan-java](https://github.com/batoulapps/adhan-java), a prayer times program, from Java to Python.\nAs it stands the project reuses most of the structure of the original project but may differ through refactoring and in an effort\nto rewrite in a more pythonic way where it makes sense.\nLike the original project there are no external dependencies except in development where [pytest](https://github.com/pytest-dev/pytest)\nand other development tools are made use of.\n\n## Requirements\n\n* Python >= 3.9\n\n## Installation\n\n```\npip install adhanpy\n```\n\n## Usage\n\nCreate a `PrayerTimes` object by passing geo coodinates, datetime and either passing a calculation method:\n\n```python\nprayer_times = PrayerTimes(coordinates, today, CalculationMethod.MOON_SIGHTING_COMMITTEE)\n```\n\nor a calculation parameters object allowing to choose from different parameters such as angles:\n\n```python\nparameters = CalculationParameters(fajr_angle=18, isha_angle=18)\nprayer_times = PrayerTimes(coordinates, today, calculation_parameters=parameters)\n```\n\nIf passing a calculation method to the calculation parameters object, the calculation method\nwill have precedence and will overwrite other parameters you may have also passed.\n\nFor instance the MOON_SIGHTING_COMMITTEE method uses a fajr angle of 18 and if for\ninstance the calculation parameters object is created by passing a different fajr angle the\nlatter will be ignored:\n\n```python\nparameters = CalculationParameters(fajr_angle=12, method=CalculationMethod.MOON_SIGHTING_COMMITTEE)\nprayer_times = PrayerTimes(coordinates, today, calculation_parameters=parameters)\nprint(parameters.fajr_angle)\n# 18.0 (the fajr_angle argument has been ignored)\n```\n\nTimes are returned in UTC time via datetime objects, for convenience it is possible to directly pass\na ZoneInfo object to PrayerTimes:\n\n```python\nlondon_zone = ZoneInfo(\"Europe/London\")\nprayer_times = PrayerTimes(\n    coordinates,\n    today,\n    CalculationMethod.MOON_SIGHTING_COMMITTEE,\n    time_zone=london_zone,\n)\n\n# this will display the time in the chosen time zone\nprint(f\"Fajr: {prayer_times.fajr.strftime('%H:%M')}\")\n```\n\nor convert to a different timezone later, each prayer time object is in fact a datetime object:\n\n```python\nprayer_times = PrayerTimes(\n    coordinates,\n    today,\n    CalculationMethod.MOON_SIGHTING_COMMITTEE,\n)\n\n# the following will be in UTC\nprint(f\"Fajr: {prayer_times.fajr.strftime('%H:%M')}\")\n\n# and to use a different timezone on the datetime object itself:\nlondon_zone = ZoneInfo(\"Europe/London\")\nprint(f\"Fajr: {prayer_times.fajr.astimezone(london_zone).strftime('%H:%M')}\")\n```\n\nA full example is located in `src/example` of the project directory.\n\n## Development\n\nTo install adhanpy for development purposes, run the following:\n\n```\npython3 -m virtualenv venv\nsource venv/bin/activate\npip install --upgrade pip\npip install -r requirements.txt\npip install -e .\n```\n\n## Licence\n\nMIT\n\n## Acknowledgments\n\nCredits go to the author of the original implementation in Java and other languages, especially the very complex astronomy\nformulas.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "An offline library calculating prayer times",
    "version": "1.0.5",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "365b89b9705b95aca620409574ce4bd4e013c33d3fd1f27edf7ab9b9ca40a18c",
                "md5": "34a1ff1f038124897bd86f93f2b6817c",
                "sha256": "79d765e6b91d3b29448988691957b51109faaca10f498eb3656e7c87b56b6066"
            },
            "downloads": -1,
            "filename": "adhanpy-1.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "34a1ff1f038124897bd86f93f2b6817c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 17178,
            "upload_time": "2023-01-28T15:54:30",
            "upload_time_iso_8601": "2023-01-28T15:54:30.328259Z",
            "url": "https://files.pythonhosted.org/packages/36/5b/89b9705b95aca620409574ce4bd4e013c33d3fd1f27edf7ab9b9ca40a18c/adhanpy-1.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "82771111dd754493146e14d4a28ac4df114cc5c74b4317055a300dd5df3df1bf",
                "md5": "bba4592a6b228fd501fa1a791c87e2c3",
                "sha256": "9b6670f8d563d61d4f9fde581165cbe692c917710b694cb6b5e2130ffc902680"
            },
            "downloads": -1,
            "filename": "adhanpy-1.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "bba4592a6b228fd501fa1a791c87e2c3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13738,
            "upload_time": "2023-01-28T15:54:32",
            "upload_time_iso_8601": "2023-01-28T15:54:32.095942Z",
            "url": "https://files.pythonhosted.org/packages/82/77/1111dd754493146e14d4a28ac4df114cc5c74b4317055a300dd5df3df1bf/adhanpy-1.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-28 15:54:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "alphahm",
    "github_project": "adhanpy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "black",
            "specs": [
                [
                    "==",
                    "22.6.0"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    "==",
                    "7.1.2"
                ]
            ]
        },
        {
            "name": "pytest-cov",
            "specs": [
                [
                    "==",
                    "3.0.0"
                ]
            ]
        },
        {
            "name": "pytest-mock",
            "specs": [
                [
                    "==",
                    "3.8.2"
                ]
            ]
        }
    ],
    "lcname": "adhanpy"
}
        
Elapsed time: 0.07830s