Skip to main content

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. The start of the prayer time intervals are the following:

Name Start of Time Range
Fajr Beginning of twilight
Sunrise Sunrise. This marks the end of Fajr and is not its own prayer
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

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 says 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)
  6. MAKKAH (Umm al-Qura)
  7. KARACHI (University Of Islamic Sciences, Karachi)

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 datetime as dt
import pytz
import tabulate


# set up calculation methods
pt = salat.PrayerTimes(salat.CalculationMethod.ISNA, salat.AsrMethod.STANDARD)

# January 1, 2000
date = dt.date(2000, 1, 1)

# using NYC
longitude = -74.0060 # degrees East
latitude = 40.7128 # degrees North
eastern = pytz.timezone('US/Eastern')

# calculate times
prayer_times = pt.calc_times(date, eastern, longitude, latitude)

# print in a table
table = [["Name", "Time"]]
for name, time in prayer_times.items():
    readable_time = time.strftime("%m/%d/%Y, %I:%M:%S %p %Z")
    table.append([name, readable_time])
print(tabulate.tabulate(table, headers='firstrow'))

Output

Name     Time
-------  ---------------------------
fajr     01/01/2000, 05:58:15 AM EST
sunrise  01/01/2000, 07:20:09 AM EST
dhuhr    01/01/2000, 11:59:25 AM EST
asr      01/01/2000, 02:20:58 PM EST
maghrib  01/01/2000, 04:38:50 PM EST
isha     01/01/2000, 06:00:44 PM EST

Planned features

  1. Adjustment for higher altitudes
  2. Options for Isha/Fajr calculation in high altitudes based on "middle of the night" and "seventh of the night" methods
  3. Add additional calculation methods

Metadata

Release files for salat 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for salat 1.1.1
File Size Uploaded Provenance Actions
salat-1.1.1.tar.gz 14.8 kB Without provenance Details for salat-1.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for salat 1.1.1
File Interpreter ABI Platform Actions
salat-1.1.1-py3-none-any.whl Python 3 none any Details for salat-1.1.1-py3-none-any.whl

Total release size: 24.8 kB

Release files / salat-1.1.1.tar.gz

Download URL salat-1.1.1.tar.gz
Size 14.8 kB
Tags Source
SHA-256 checksum
How to use checksums
59ad599a3ca4b7cb7b9edd44b1d1900b3bd69551624814aba00f3d8aa5608223
BLAKE2b-256 checksum
How to use checksums
d045720a09f019b20e1504acbcf88cbb4019a23221d36918417c0d5831a8c871
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / salat-1.1.1-py3-none-any.whl

Download URL salat-1.1.1-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
63b3316540ece181828d9370e74838c1ee94139f9d574467c1d248e34fae40f0
BLAKE2b-256 checksum
How to use checksums
1e765d69dd7ee5bb5caf395da680e2e2af35f445a2fe1b1adf427a8001f4e7ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for salat 1.1.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page