Skip to main content

Tool to calculate accurate salat (prayer) times

Project description

salat

One of the pillars of Islam is salat, which is the act of praying five times a day. Each prayer has a specific time interval, defined in terms of the Sun's position so anyone anywhere in the world can know when it is time to pray.

However with modern computation most Muslims use calculated prayer times to determine when to pray instead of watching the Sun. This package performs accurate calculations using orbital dynamics equations instead of common approximations, and native Python tools like datetime to calculate these times.

Prayer Times

In general terms, the time range of a prayer is from it's start until the start of the next prayer, except for Fajr which ends at sunrise and Isha which is recommended to end before midnight. The start of the prayer time intervals are the following:

Name Start of Time Range
Fajr Beginning of twilight
Sunrise Sunrise. Note that this marks the end of Fajr
Dhuhr When the Sun passes its zenith
Asr When the length of a shadow is the same as the length of the object (or with Hanafi method, twice the length of the object) plus its length when the Sun is at zenith
Maghrib Sunset
Isha When the red light of sunset is gone
Midnight Halfway point of the night. Note that this marks the recommended end of Isha

However there are various methods and standards for what exact times these general terms correspond to. For example, according to the Muslim World League, Fajr starts when the altitude of the Sun is 18 degrees below the horizon, while the Islamic Society of North America determined it's when the sun is 15 degrees below the horizon.

Motivation

There are many websites with prayer time tables and apps that show automatically updating prayer times for your location for each day. However there are not many Python ones, and they either query the websites for time tables or use approximate methods.

This package has the following goals:

  1. Accurate calculations using exact equations and high precision parameters where possible
  2. Use developer friendly interface including datetimes and typehints
  3. Support several calculation methods

Supported methods

This package supports the following calculation methods:

  1. ISNA (Islamic Society of North America)
  2. MWL (Muslim World League)
  3. Egypt (Egyptian General Authority of Survey)
  4. Tehran (Institute of Geophysics, University of Tehran)
  5. Jafari (Shia Ithna Ashari, Leva Research Institute, Qum)

There are many more methods in use around the world, so if there's any missing that you would like to see please submit an issue.

Installation

pip install salat

Example code

import salat
import pytz
from datetime import datetime

pt = salat.PrayerTimes(salat.CalculationMethod.ISNA)
eastern = pytz.timezone('US/Eastern')
# address of NYC
longitude = -74.0060 # degrees East
latitude = 40.7128 # degrees North

prayer_times = pt.calc_times(datetime.now().date(), eastern, longitude, latitude)
for name, prayer_time in prayer_times.items():
    print(name, prayer_time)

Planned features

  1. Adjustment for higher altitudes
  2. Options for Isha/Fajr calculation in high altitudes based on "middle of the night" and "sevent of the night" methods
  3. Add additional calculation methods like Makkah method by Umm al-Qura University, Makkah

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

salat-0.0.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

salat-0.0.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file salat-0.0.0.tar.gz.

File metadata

  • Download URL: salat-0.0.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for salat-0.0.0.tar.gz
Algorithm Hash digest
SHA256 d0d289e6a1f3b1f6329ecf08963c929c1ee4370cdac791e7850a0885e73a37e5
MD5 e8bc1d6edf7e72f8fcdd6f649ad02fa6
BLAKE2b-256 88dbfa0421f70a8b47207ec5484bcc7d67272bd34ce17b37c1fda56ae187c5c8

See more details on using hashes here.

File details

Details for the file salat-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: salat-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for salat-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6378dd44c1b769357ce26766fd5f3947c9b23d95fb48fd0c3e39097a1ec1cc34
MD5 c97a94dfd00477d62cbc13b34ee9946a
BLAKE2b-256 9c1070b8a8039ebfea66df295fc463bb1330de95cc0d2ab76e915beb4dd7de55

See more details on using hashes here.

Supported by

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