Skip to main content

Prayer times, part 5: Asr and the shadow

· 21 min read
Rizki Rakasiwi
Muslimtify maintainer

Every prayer so far has been about the horizon: the sun crossing it, or sitting some number of degrees below it. Asr is different. Asr is about a shadow.

That makes it the one prayer time you can measure with no instrument but a stick, and it is also the one prayer whose time is set by your madhhab rather than by your country. Both of those facts come straight out of the texts in part 1, and both end up as a single line in the code.

This is part 5 of a series

Part 1 covered the sources. Part 2 found the sun. Part 3 computed sunrise, Dhuhr and Maghrib. Part 4 computed Fajr and Isha. This part completes the five. The full series is under the prayer time calculation tag.

What the texts say​

The hadith of Abdullah ibn Amr in part 1 gives the end of Dhuhr and the start of Asr in one phrase: Dhuhr lasts from the sun's decline "for as long as a man's shadow is the length of his height, until Asr has come". Asr begins when your shadow is as long as you are tall.

The hadith of Jibril adds the detail that split the schools. On the first day Jibril prayed Asr "when the shadow of a thing was equal to it", and on the second day "when the shadow of a thing was twice it". Malik, ash-Shafi'i and Ahmad read the first day as the start of Asr and the second as its preferred end. Abu Hanifa read the second day as the start. So for three schools Asr begins at one shadow length, and for the Hanafi school at two.

There is one more detail the jurists added, and it matters for the math. At noon a stick already has a shadow, short or long depending on the season and where you live. The schools agree that this noon shadow, fay' az-zawal, does not count. Asr begins when the shadow has grown by one stick height beyond whatever it was at noon, or by two for the Hanafi school.

heightnoon shadownoon shadow + height, Asr (standard)noon shadow + 2 × height, Asr (Hanafi)the sun sinks to the left as the afternoon goes on
The stick from part 1. At noon the shadow is at its shortest. Asr begins when the shadow has grown by the stick's own height (most schools) or by twice its height (Hanafi). The noon shadow is drawn long here to make the construction clear; in Jakarta in October it is a few percent of the height.

From a shadow to an angle​

A stick's shadow is simple geometry. If the sun is at altitude a above the horizon, a stick of height 1 casts a shadow of length 1 / tan(a). High sun, short shadow. Low sun, long shadow.

At noon the sun is as high as it gets, and from part 2 we know how high: it is overhead minus the gap between your latitude and today's declination. In Jakarta on 17 October 2026 that gap is 3.0°, so the noon sun is 87.0° up and the noon shadow is tan(3.0°), about 0.05 stick heights. In Istanbul the same day the gap is 50.2° and the noon shadow is 1.2 stick heights, already longer than the stick.

Asr begins when the shadow equals the noon shadow plus one stick height (or two). Put that into the shadow formula and solve for the altitude:

noon_shadow = tan( |latitude - declination| )
shadow at Asr = noon_shadow + n n = 1 for most schools, 2 for Hanafi
altitude at Asr = atan( 1 / (noon_shadow + n) )

For Jakarta on 17 October: atan(1 / (0.05 + 1)) is 43.5°, and atan(1 / (0.05 + 2)) is 26.0°. Asr begins when the afternoon sun has come down to 43.5° above the horizon, or 26.0° for the Hanafi school.

0×1×2×3×4×11:0012:0013:0014:0015:0016:0017:00shadow length, in stick heightsstandard Asr 14:45noon shadow + 1Hanafi Asr 15:56noon shadow + 2noon, shadow 0.05×
A stick's shadow in Jakarta on 17 October 2026, measured in stick heights. The sun is almost overhead at noon so the shadow nearly vanishes, then it lengthens faster and faster. Asr is where the curve crosses the dashed lines.

And now we are back on familiar ground. "At what time does the sun reach 43.5° above the horizon, after noon?" is exactly the question sun_event from part 3 answers. The only difference from every earlier use is that the altitude is positive. The function does not care.

Why Asr is a madhhab setting, not a country setting​

Look at what goes into the Asr altitude: your latitude, today's declination, and the number n. There is no twilight, no observation of the sky, nothing for a national authority to measure and decide. The only choice is n, and n is a question of which reading of the hadith of Jibril you follow. That is a question of madhhab.

So Muslimtify keeps Asr separate from the calculation method. You pick Kemenag or Diyanet or ISNA for Fajr and Isha, and you pick your madhhab for Asr, and the two settings do not touch. A Hanafi in Jakarta uses Kemenag's 20° and the two-shadow Asr. A Shafi'i in Istanbul uses Diyanet's angles and the one-shadow Asr. The calculation methods page in the docs describes the setting.

The code​

Add this to the file from part 3, in place of its last block. asr_altitude is the formula above. asr computes the noon declination, turns it into the altitude, and hands the altitude to sun_event to find the time.

def asr_altitude(latitude, declination, shadow_factor):
"""Sun altitude when a stick's shadow is its noon shadow plus shadow_factor times its height."""
noon_zenith = abs(latitude - declination) # degrees between the noon sun and straight overhead
return math.degrees(math.atan(1 / (shadow_factor + math.tan(math.radians(noon_zenith)))))

def asr(jd, latitude, longitude, timezone, shadow_factor=1):
noon = solar_noon(jd, longitude, timezone)
declination, _ = sun_position(jd + (noon - timezone) / 24)
altitude = asr_altitude(latitude, declination, shadow_factor)
return sun_event(jd, latitude, longitude, timezone, altitude, +1)

if __name__ == "__main__":
jd = julian_day(2026, 10, 17)
lat, lon, tz = -6.2088, 106.8456, 7 # Jakarta, WIB
standard = asr(jd, lat, lon, tz, 1)
hanafi = asr(jd, lat, lon, tz, 2)
print(f"asr, shadow = height {hm(standard)} (Shafi'i, Maliki, Hanbali)")
print(f"asr, shadow = 2 x height {hm(hanafi)} (Hanafi)")
ihtiyat = 2 / 60
print(f"kemenag {hm(standard + ihtiyat, round_up=True)} (standard, +2 min, rounded up)")

One subtlety. asr_altitude uses the declination at noon, and sun_event then refines the time using the declination at Asr itself. Between noon and Asr the declination moves by a few hundredths of a degree, which changes the shadow by less than a thousandth of a stick height. libmuslim takes the slightly simpler route of using the start-of-day declination for the whole Asr calculation. The two agree to within four seconds for Jakarta, which is why the post does not bother to recompute the altitude inside the loop.

Check your work​

Run it. For Jakarta on 17 October 2026 you should see:

asr, shadow = height 14:45 (Shafi'i, Maliki, Hanbali)
asr, shadow = 2 x height 15:56 (Hanafi)
kemenag 14:48 (standard, +2 min, rounded up)

The last line is the Kemenag timetable's Asr for Jakarta and what Muslimtify shows by default. Switch the madhhab setting to Hanafi and it will show 15:59, the second line plus the same two minutes and rounding.

The gap between the two schools is 71 minutes in Jakarta today. It is not the same everywhere: the shadow grows faster when the sun is lower in the sky, so in winter at higher latitudes the two Asrs can be less than half an hour apart, and in Jakarta, where the afternoon sun stays high for a long time, they are further apart than almost anywhere.

Then the stick test, which for Asr is the real thing and not a metaphor. Find a straight stick, a pole, or a doorframe on flat ground in the sun. At 11:38 measure its shadow and mark the length. Then add the stick's own height to that mark. When the shadow reaches the new mark, look at your watch. If the sky is clear, it will say 14:45, give or take the care you took with the measuring. You have just computed Asr the way the Companions did.

What to carry into the rest of the series​

With Asr the five prayers are complete. Every one of them reduced to the same shape: a date gives the sun's declination and the equation of time, those plus your longitude give solar noon, and noon plus an hour angle gives the time the sun reaches some altitude. The altitude is −0.833° for sunrise and sunset, a twilight angle for Fajr and Isha, and a shadow angle for Asr. The whole timetable is one formula asked five ways.

What remains is the part that is not astronomy. Part 6 goes through the national standards one by one, Kemenag, Diyanet, Umm al-Qura and the rest, and shows what each one adds on top of the formula: precaution minutes, rounding rules, Ramadan exceptions, and the regional corrections that Muslimtify intentionally leaves out. Part 7, the last, deals with the places where the formula gives no answer at all, in the far north, and with the clock, which is not astronomy either. Then it puts everything into a single program and checks it against libmuslim for a whole year.