# Prayer Times Calculator
This Python script calculates Islamic prayer times based on a user's location, the date, and a selected calculation method. Originally developed by Hamid Zarrabi-Zadeh, it was later adapted to Python by Saleem Shafi, Hamid Zarrabi-Zadeh and Mohammad Rahimi.
---
## Features
- Calculates the times for Islamic prayers, including Fajr, Dhuhr, Asr, Maghrib, and Isha, for any geographic location.
- Supports multiple established calculation methods, such as MWL, ISNA, Umm Al-Qura, and Jafari.
- Includes settings tailored for high-latitude locations where the sun's behavior may vary significantly.
- Allows users to customize prayer time offsets.
- Offers output formats in both 12-hour and 24-hour clock styles.
---
## Requirements
To run this script, you will need:
- Python version 3.x or later.
- The built-in `math` and `re` modules, which come pre-installed with Python.
---
## How to Use
### 1. Initialize the `PrayTimes` Class
To begin, create an instance of the `PrayTimes` class, specifying your desired calculation method. For example:
```python
from praytimes import PrayTimes
PT = PrayTimes('MWL')
```
### 2. Calculate Prayer Times
To compute prayer times for a specific date and location, use the `get_times` method. This method requires the date, geographic coordinates (latitude, longitude, and optionally elevation), the time zone offset, daylight saving adjustment (if applicable), and the desired time format.
```python
from datetime import date
# Initialize PrayTimes
PT = PrayTimes('Tehran')
# Specify Coordinates (latitude, longitude)
coordinates = (34.641159, 50.877456)
timezone = 3.5 # Time zone offset from UTC
times = PT.get_times(date.today(), coordinates, timezone)
print(times)
```
**Example Output:**
```plaintext
{
'imsak': '05:10',
'fajr': '05:20',
'sunrise': '06:50',
'dhuhr': '12:15',
'asr': '15:20',
'sunset': '18:45',
'maghrib': '18:55',
'isha': '20:15',
'midnight': '00:35'
}
```
---
## Key Methods and Functions
### `get_times(date, coordinates, timezone, dst=0, format=None)`
This method calculates prayer times for a given date and location.
- **`date`**: Accepts either a tuple `(year, month, day)` or a `datetime.date` object.
- **`coordinates`**: A tuple specifying `(latitude, longitude, [elevation])`.
- **`timezone`**: The time zone offset from UTC.
- **`dst`**: Optional daylight saving time adjustment (default is `0`).
- **`format`**: Optionally specify time output format (`12h` or `24h`).
### `set_method(method)`
This method sets the prayer time calculation method.
- Supported methods include `MWL`, `ISNA`, `Egypt`, `Makkah`, `Karachi`, `Tehran`, and `Jafari`.
### `adjust(parameters)`
Use this method to modify calculation parameters, such as those for Imsak or Maghrib.
### `tune(offsets)`
This function allows you to fine-tune computed prayer times by applying custom offsets in minutes.
### `get_method()` and `get_settings()`
These methods retrieve the currently selected calculation method and its associated parameters.
---
## Calculation Methods
Each supported method uses specific angle values to determine Fajr and Isha timings. For instance:
- **MWL (Muslim World League)**: Fajr at 18°, Isha at 17°
- **ISNA (Islamic Society of North America)**: Fajr at 15°, Isha at 15°
- **Tehran (Institute of Geophysics, University of Tehran)**: Fajr at 17.7°, Maghrib 4.5° after sunset, Isha at 14°
---
## Example Output
When run directly, the script outputs prayer times for today using a sample location:
```plaintext
Prayer Times for today in Waterloo/Canada
=========================================
imsak: 05:10
fajr: 05:20
sunrise: 06:50
dhuhr: 12:15
asr: 15:20
sunset: 18:45
maghrib: 18:55
isha: 20:15
midnight: 00:35
```
---
## License
This script is distributed under the GNU LGPL v3.0 license. Proper credit should be given to the original authors, with a link to [PrayTimes.org](http://praytimes.org).
---
## Acknowledgments
- Original JavaScript Code: Hamid Zarrabi-Zadeh
- Python Adaptation: Saleem Shafi and Hamid Zarrabi-Zadeh, Mohammad Rahimi
For more details about the calculations, see the [user manual](http://praytimes.org/manual) and [calculation formulas](http://praytimes.org/calculation).
Project [link](https://pypi.org/project/religious-times/) on **Pypi.org**
Project on **GitHub**: [religious_times](https://github.com/zamoosh/religious_times)
Raw data
{
"_id": null,
"home_page": "https://github.com/zamoosh/religious_times/",
"name": "religious-times",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "pray, muslim, prayer, fajr, imsak, sunrise, duhr, asr, sunset, maghrib, isha, midnight, religious times, shia",
"author": "Saleem Shafi, Hamid Zarrabi-Zadeh, Mohammad Rahimi (zamoosh)",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/18/1f/11ace49406511247e42be4467b2c121516ce5892a681a462655aa7bff6c4/religious_times-2.6.tar.gz",
"platform": null,
"description": "# Prayer Times Calculator\n\nThis Python script calculates Islamic prayer times based on a user's location, the date, and a selected calculation method. Originally developed by Hamid Zarrabi-Zadeh, it was later adapted to Python by Saleem Shafi, Hamid Zarrabi-Zadeh and Mohammad Rahimi.\n\n---\n\n## Features\n\n- Calculates the times for Islamic prayers, including Fajr, Dhuhr, Asr, Maghrib, and Isha, for any geographic location.\n- Supports multiple established calculation methods, such as MWL, ISNA, Umm Al-Qura, and Jafari.\n- Includes settings tailored for high-latitude locations where the sun's behavior may vary significantly.\n- Allows users to customize prayer time offsets.\n- Offers output formats in both 12-hour and 24-hour clock styles.\n\n---\n\n## Requirements\n\nTo run this script, you will need:\n\n- Python version 3.x or later.\n- The built-in `math` and `re` modules, which come pre-installed with Python.\n\n---\n\n## How to Use\n\n### 1. Initialize the `PrayTimes` Class\n\nTo begin, create an instance of the `PrayTimes` class, specifying your desired calculation method. For example:\n\n```python\nfrom praytimes import PrayTimes\nPT = PrayTimes('MWL')\n```\n\n### 2. Calculate Prayer Times\n\nTo compute prayer times for a specific date and location, use the `get_times` method. This method requires the date, geographic coordinates (latitude, longitude, and optionally elevation), the time zone offset, daylight saving adjustment (if applicable), and the desired time format.\n\n```python\nfrom datetime import date\n\n# Initialize PrayTimes\nPT = PrayTimes('Tehran')\n\n# Specify Coordinates (latitude, longitude)\ncoordinates = (34.641159, 50.877456)\ntimezone = 3.5 # Time zone offset from UTC\n\ntimes = PT.get_times(date.today(), coordinates, timezone)\nprint(times)\n```\n\n**Example Output:**\n\n```plaintext\n{\n 'imsak': '05:10',\n 'fajr': '05:20',\n 'sunrise': '06:50',\n 'dhuhr': '12:15',\n 'asr': '15:20',\n 'sunset': '18:45',\n 'maghrib': '18:55',\n 'isha': '20:15',\n 'midnight': '00:35'\n}\n```\n\n---\n\n## Key Methods and Functions\n\n### `get_times(date, coordinates, timezone, dst=0, format=None)`\n\nThis method calculates prayer times for a given date and location.\n\n- **`date`**: Accepts either a tuple `(year, month, day)` or a `datetime.date` object.\n- **`coordinates`**: A tuple specifying `(latitude, longitude, [elevation])`.\n- **`timezone`**: The time zone offset from UTC.\n- **`dst`**: Optional daylight saving time adjustment (default is `0`).\n- **`format`**: Optionally specify time output format (`12h` or `24h`).\n\n### `set_method(method)`\n\nThis method sets the prayer time calculation method.\n\n- Supported methods include `MWL`, `ISNA`, `Egypt`, `Makkah`, `Karachi`, `Tehran`, and `Jafari`.\n\n### `adjust(parameters)`\n\nUse this method to modify calculation parameters, such as those for Imsak or Maghrib.\n\n### `tune(offsets)`\n\nThis function allows you to fine-tune computed prayer times by applying custom offsets in minutes.\n\n### `get_method()` and `get_settings()`\n\nThese methods retrieve the currently selected calculation method and its associated parameters.\n\n---\n\n## Calculation Methods\n\nEach supported method uses specific angle values to determine Fajr and Isha timings. For instance:\n\n- **MWL (Muslim World League)**: Fajr at 18\u00b0, Isha at 17\u00b0\n- **ISNA (Islamic Society of North America)**: Fajr at 15\u00b0, Isha at 15\u00b0\n- **Tehran (Institute of Geophysics, University of Tehran)**: Fajr at 17.7\u00b0, Maghrib 4.5\u00b0 after sunset, Isha at 14\u00b0\n\n---\n\n## Example Output\n\nWhen run directly, the script outputs prayer times for today using a sample location:\n\n```plaintext\nPrayer Times for today in Waterloo/Canada\n=========================================\nimsak: 05:10\nfajr: 05:20\nsunrise: 06:50\ndhuhr: 12:15\nasr: 15:20\nsunset: 18:45\nmaghrib: 18:55\nisha: 20:15\nmidnight: 00:35\n```\n\n---\n\n## License\n\nThis script is distributed under the GNU LGPL v3.0 license. Proper credit should be given to the original authors, with a link to [PrayTimes.org](http://praytimes.org).\n\n---\n\n## Acknowledgments\n\n- Original JavaScript Code: Hamid Zarrabi-Zadeh\n- Python Adaptation: Saleem Shafi and Hamid Zarrabi-Zadeh, Mohammad Rahimi\n\nFor more details about the calculations, see the [user manual](http://praytimes.org/manual) and [calculation formulas](http://praytimes.org/calculation).\n\nProject [link](https://pypi.org/project/religious-times/) on **Pypi.org** \n\nProject on **GitHub**: [religious_times](https://github.com/zamoosh/religious_times)\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A library to calculate `pray times` for muslims.",
"version": "2.6",
"project_urls": {
"Homepage": "https://github.com/zamoosh/religious_times/"
},
"split_keywords": [
"pray",
" muslim",
" prayer",
" fajr",
" imsak",
" sunrise",
" duhr",
" asr",
" sunset",
" maghrib",
" isha",
" midnight",
" religious times",
" shia"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "95567dc069b821b809462c42bee63716841fc041d213c5416b29f55083894e96",
"md5": "409643f9f6d9b196f00cd8f71e7527e7",
"sha256": "60311a641ebcb089e678940c9a3479b8cdbee83da8df4d8eca87f02243a57fd2"
},
"downloads": -1,
"filename": "religious_times-2.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "409643f9f6d9b196f00cd8f71e7527e7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 3122,
"upload_time": "2025-01-06T08:32:22",
"upload_time_iso_8601": "2025-01-06T08:32:22.666992Z",
"url": "https://files.pythonhosted.org/packages/95/56/7dc069b821b809462c42bee63716841fc041d213c5416b29f55083894e96/religious_times-2.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "181f11ace49406511247e42be4467b2c121516ce5892a681a462655aa7bff6c4",
"md5": "113a8fd0ff3014699bfd2643fb11c5fc",
"sha256": "628510254cf4090dbfa6b65aca799625fa64815aba1530894402bd7d83bbac4e"
},
"downloads": -1,
"filename": "religious_times-2.6.tar.gz",
"has_sig": false,
"md5_digest": "113a8fd0ff3014699bfd2643fb11c5fc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3238,
"upload_time": "2025-01-06T08:32:23",
"upload_time_iso_8601": "2025-01-06T08:32:23.684434Z",
"url": "https://files.pythonhosted.org/packages/18/1f/11ace49406511247e42be4467b2c121516ce5892a681a462655aa7bff6c4/religious_times-2.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-06 08:32:23",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "zamoosh",
"github_project": "religious_times",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "religious-times"
}