Every few weeks someone opens an issue on a prayer times project saying the app is "wrong" by a minute. It almost never is. Prayer times are not stored values, they are solved values, and the solution has parameters. Once you know the parameters, every minute of difference becomes explainable.
A prayer time is an angle, not a clock value
Five of the six daily markers are defined by the position of the sun relative to the horizon at a given latitude and longitude:
- Fajr: the sun is a certain number of degrees below the horizon before sunrise.
- Sunrise: the upper limb of the sun crosses the horizon.
- Dhuhr: the sun crosses the local meridian, plus a small safety offset.
- Asr: the length of an object's shadow reaches a given ratio of the object's height.
- Maghrib: sunset.
- Isha: the sun is a certain number of degrees below the horizon after sunset.
So the computation is: solar declination and the equation of time for the date, then solve the hour angle for the required altitude, then convert to local civil time. Nothing in that chain is a lookup table.
Where the first minutes come from: Fajr and Isha angles
The angle for Fajr and Isha is a convention, not a constant of nature. Common values in use:
| Method | Fajr | Isha |
|---|---|---|
| Muslim World League | 18 | 17 |
| Egyptian General Authority | 19.5 | 17.5 |
| University of Islamic Sciences, Karachi | 18 | 18 |
| ISNA (North America) | 15 | 15 |
| Umm al-Qura | 18.5 | 90 minutes after Maghrib |
Two apps in the same city with 18 and 19.5 degrees for Fajr are not one minute apart, they are often five to eight minutes apart, and both are internally correct. Notice also that Umm al-Qura does not use an angle for Isha at all, it uses a fixed interval. Any code that assumes "every method is an angle pair" will produce wrong results for it.
Asr: the same instant, two definitions
Asr is a shadow ratio. The standard opinion uses a ratio of 1, the Hanafi opinion uses 2. That is not a rounding difference, it is typically 30 to 60 minutes depending on latitude and season. If your users can pick a school, this must be a separate setting, not bundled inside the method.
High latitudes: when the equation has no solution
Above roughly 48 degrees, in parts of the year the sun never goes 18 degrees below the horizon. The equation simply has no root, and a naive implementation returns NaN or throws. The three conventions in practical use:
- Middle of the night: split the interval between sunset and sunrise, use the midpoint as the boundary.
- One seventh of the night: allocate a seventh of the night to Isha and a seventh before Fajr.
- Angle-based: scale the portion of the night by the method angle.
Whichever you pick, log it in the response. A user in Stockholm deserves to know that the displayed Fajr came from a fallback rule rather than a solar angle.
Rounding, offsets and the timezone tail
The last minute of difference usually hides here:
- Rounding: flooring versus rounding to the nearest minute shifts half the rows by one minute.
- Dhuhr offset: many tables add one to five minutes after true solar noon.
- Elevation: an altitude correction for sunrise and sunset moves them by a minute or two in mountain cities.
- Timezone: computing in UTC and formatting with a fixed offset instead of an IANA zone breaks every DST transition day.
A quick way to see it yourself
Compute one city with two methods and diff the columns:
import { CalculationMethod, Coordinates, PrayerTimes } from "adhan";
const coords = new Coordinates(41.0082, 28.9784); // Istanbul
const date = new Date(2027, 5, 21);
for (const name of ["MuslimWorldLeague", "Egyptian", "Karachi"]) {
const t = new PrayerTimes(coords, date, CalculationMethod[name]());
console.log(name, t.fajr.toISOString(), t.isha.toISOString());
}
Run it across a full year and the pattern becomes obvious: the gap is not noise, it tracks the angle difference and grows with latitude and season.
What this means for your API design
If you expose prayer times over HTTP, return the parameters with the data: method name, Fajr and Isha angles, Asr school, high latitude rule, and the IANA timezone used. Then a mismatch becomes a diff of parameters instead of an argument about who is right.
That is the approach we took while building the public prayer times and Qibla API behind Wesalna, documented at https://wesalna.com/developers. Every response states the method it used, so a one minute difference is always traceable to a parameter rather than a mystery.
Top comments (0)