PrayTime Manual
Contents
  1. Introduction
  2. Download and Examples
  3. General Usage
  4. Main Functions
  5. Calculating Methods
    1. Asr Method
    2. Adjusting Functions
    3. Adjustments for Higher Latitudes
  6. Formatting Functions
  7. Mathematical Formulas

Introduction

PrayTime is a small program providing a set of handy functions to calculate prayer times based on a variety of conventions usually used in Muslim communities.

PrayTime is originally written in JavaScrip. This manual provides information on how to use PrayTime on a web-page or Javascript-based widget to obtain prayer times at any given time and location.

Download and Examples

Download:

Examples:

General Usage

The first step for using PrayTime in a web-page is to include prayTime.js into the page, using a code like this:

 <script type="text/javascript" src="prayTime.js"></script> 
After including prayTime.js, an object named prayTime is created and is ready to use. We can immediately get the prayer times (using the default settings) from this object. For example, to get today's prayer times for a location with latitude 43, longitude -80 and time zone -5, we can call:
 prayTime.getPrayerTimes(new Date(), 43, -80, -5); 
There are several functions to adjust various prayer times calculation parameters. For example, we can call the following function (before calling getPrayerTimes) to change the calculation method from its default (Ithna Ashari) to ISNA:
 prayTime.setCalcMethod(prayTime.ISNA); 
Details of all functions and their usage are described below.

Main Functions

There are two main functions for retrieving prayer times for a given time and location:

getPrayerTimes (date, latitude, longitude, timeZone)
getDatePrayerTimes (year, month, day, latitude, longitude, timeZone)

The parameter date specifies the date for which prayer times are calculated. You can use new Date() to specify today. latitude and longitude specify the coordinates of the location for which the times are calculated, and timeZone specifies the time offset of the location with respect to the GMT. getDatePrayerTimes is the same as getPrayerTimes, except that instead of receiving a Date object as the first parameter, it receives the date as a triple of <year, month, day>.

Both functions return an array of size 7 containing the times <Fajr, Sunrise, Dhuhr, Asr, Sunset, Maghrib, Isha> for the given date and location (see here for the definition of the times).

Notes:

Calculating Methods

There are several conventions for calculating prayer times. The default convention used in PrayTime is Itha Ashari. However, you can change the calculation method using the following function:

setCalcMethod(methodID)

The available values for methodID are listed in the table below:

MethodID Method Name Fajr Angle Isha Angle Maghrib Angle
Jafari Shia Ithna Ashari (Ja'fari) 16 14 4
Karachi University of Islamic Sciences, Karachi 18 18 = Sunset
ISNA Islamic Society of North America (ISNA) 15 15 = Sunset
MWL Muslim World League (MWL) 18 17 = Sunset
Makkah Umm al-Qura, Makkah 19 90 mins after Maghrib = Sunset
Egypt Egyptian General Authority of Survey 19.5 17.5 = Sunset

The above methodID's are defined inside class PrayTime, and can be accessed through prayTime object. For example, to set the calculation method to Muslim World League (MWL), you can use prayTime.setCalcMethod(prayTime.MWL).

Asr Method

The juristic method for computing Asr can be set using the following function:

setAsrMethod(methodID)

The available values for methodID are listed in the table below:

MethodID Description
Shafii The method used by the majority of schools, including Shafi'i, Maliki, and Hanbali.
Hanafi The method used in Hanafi's school of thought.

The difference between these two juristic methods can be found here. The default juristic method used in PrayTime is Shafii. You can change it to Hanafi by calling prayTime.setAsrMethod(prayTime.Hanafi).

Adjusting Functions

Apart from the general functions available for determining the calculation methods, one can also adjust calculating parameters using the following set of function:

setFajrAngle(angle)
setMaghribAngle(angle)
setIshaAngle(angle)

The angle parameter defines the twilight angle (in degrees) that should be used to calculate the corresponding time. For example, to set the Fajr twilight angle to 17 degrees, one can call prayTime.setFajrAngle(17).

There are also a set of functions for adjusting the times by defining the time differences in minutes:

setDhuhrMinutes(minutes)
setMaghribMinutes(minutes)
setIshaMinutes(minutes)

In setDhuhrMinutes function, minutes specifies the time difference between mid-day and Dhuhr. In setMaghribMinutes function, minutes specifies the time difference between Sunset and Maghrib. In setIshaMinutes function, minutes specifies how many minutes after Maghrib should be considered as Isha. For example, to set Maghrib as 15 minutes after Sunset, we can use prayTime.setMaghribMinutes(15).

Adjustment for Higher Latitudes

In locations at higher latitude, twilight may persist throughout the night during some months of the year. Several solutions for this problem has been implemented in PrayTime that can be set using the following function:

setHLAdjustMethod(methodID)

The available values for methodID are listed in the table below:

MethodID Description
None No adjustments
MidNight The middle of the night method
OneSeventh The 1/7th of the night method
AngleBased The adaptive angle based method

The descriptions for the above methods can be found here. The default method used in PrayTime is MidNight.

Formatting Functions

The default time format used to output prayer times in calculating functions is 24-hour format. The time format can be changed using the following function:

setTimeFormat(timeFormat)

The available values for timeFormat are listed in the table below:

Time Format Description
Time24 24-hour clock format
Time12 12-hour clock format (with am and pm suffixes)
Time12NS 12-hour clock format with no suffix
Float Floating point number

For example, to change the output format from 24-hour to 12-hour, it suffices to call prayTime.setTimeFormat(prayTime.Time12).

If the times are maintained in floating points, the following functions can be used to change them to other time formats:

floatToTime24(time)
floatToTime12(time)
floatToTime12NS(time)

For example, calling the function prayTime.floatToTime12(15.2) returns the string 3:12 pm.

Mathematical Formulas

The mathematical formulas used to calculate the prayer times are fully described in this page.