Overview
ThePrayTime class is the core calculation engine for Praydo, providing astronomical calculations for Islamic prayer times. Itβs based on the PrayTimes.org library v3.2 by Hamid Zarrabi-Zadeh.
Constructor
The calculation method to use. Available methods:
'MWL'- Muslim World League'ISNA'- Islamic Society of North America'Egypt'- Egyptian General Authority of Survey'Makkah'- Umm Al-Qura University, Makkah'Karachi'- University of Islamic Sciences, Karachi'Tehran'- Institute of Geophysics, University of Tehran'Jafari'- Shia Ithna-Ashari, Leva Institute, Qum'France'- Union des Organisations Islamiques de France'Russia'- Spiritual Administration of Muslims of Russia'Singapore'- Majlis Ugama Islam Singapura'NU'- Nahdlatul Ulama Indonesia'MU'- Muhammadiyah Indonesia
Example
Configuration Methods
All configuration methods return thePrayTime instance for method chaining.
method()
Set the calculation method.The calculation method to use
location()
Set the geographical location for prayer times calculation.An array containing
[latitude, longitude] coordinates.- Latitude: -90 to 90 (negative for South, positive for North)
- Longitude: -180 to 180 (negative for West, positive for East)
Examples
timezone()
Set the timezone for prayer times calculation.A string representing the IANA timezone identifier (e.g.,
'America/New_York', 'Asia/Jakarta', 'Europe/London')Examples
adjust()
Adjust the calculation parameters for prayer times calculation.An object containing any of the following parameters:
- fajr: Twilight angle for Fajr (number)
- dhuhr: Minutes after mid-day (string with βminβ)
- asr: Asr juristic method -
'Standard'(Shafii, Maliki, Jafari, Hanbali - shadow factor = 1) or'Hanafi'(shadow factor = 2) - maghrib: Twilight angle (number) or minutes after sunset (string with βminβ)
- isha: Twilight angle (number) or minutes after Maghrib (string with βminβ)
- midnight: Midnight method -
'Standard'(mean time from Sunset to Sunrise) or'Jafari'(mean time from Maghrib to Fajr) - highLats: Higher latitudes adjustment method -
'NightMiddle','OneSeventh','AngleBased', or'None'
Example
tune()
Fine-tune prayer times by adding or subtracting minutes.An object mapping prayer names to minute adjustments (can be positive or negative)
Example
format()
Set the output time format.The time format to use:
'24h'- 24-hour format (e.g., β13:45β)'12h'- 12-hour format with AM/PM (e.g., β1:45 PMβ)'12H'- 12-hour format without AM/PM (e.g., β1:45β)'x'- Unix timestamp in milliseconds'X'- Unix timestamp in seconds- Custom function:
(timestamp: number) => string
Example
round()
Set the rounding method for prayer times.The rounding method:
'nearest'- Round to nearest minute'up'- Round up (ceiling)'down'- Round down (floor)'none'- No rounding
utcOffset()
Set UTC offset in minutes.UTC offset in minutes, or
'auto' to use system timezoneCalling this method sets the timezone to
'UTC'.utcOffsetHours()
Set UTC offset in hours.UTC offset in hours
Calculation Methods
getTimes()
Get prayer times for a specific date, location, and timezone.The date for which to calculate prayer times:
- Date object:
new Date() - Timestamp: Unix timestamp in milliseconds
- Days offset: Number < 1000 (e.g.,
0= today,1= tomorrow,-1= yesterday) - Array:
[year, month, day](month is 1-based)
Coordinates
[latitude, longitude]. If not provided, uses previously set location.IANA timezone string (e.g.,
'Asia/Jakarta') or UTC offset in hoursDaylight Saving Time adjustment in hours (usually 0 or 1)
Output time format
An object containing prayer times with the following keys:
fajr- Fajr prayer timesunrise- Sunrise timedhuhr- Dhuhr prayer timeasr- Asr prayer timesunset- Sunset timemaghrib- Maghrib prayer timeisha- Isha prayer timemidnight- Midnight time
Examples
times()
Get prayer times using previously configured location and timezone.The date for which to calculate prayer times
An object containing prayer times
Example
Type Definitions
CalculationMethod
MethodParams
AsrMethod
HighLatitudeMethod
MidnightMethod
RoundingMethod
TimeFormat
Complete Usage Example
Attribution
Based on PrayTimes.org library v3.2Copyright (c) 2007-2025 Hamid Zarrabi-Zadeh
License: MIT
Source: https://praytimes.org