← All writing

Prayer times that match the official tables to the minute

I made a prayer-times app for Tunisia that works the times out on the phone, offline. The hard part was finding the exact rules behind the official tables.

·4 min read
Tunisia Prayer Times on a computer and on a phone: today's times for Tunis with a countdown to Maghrib, and on the phone the Ramadan card counting down to iftar.

Prayer times in Tunisia don’t always agree from one source to the next, and a minute or two matters. In Ramadan, Maghrib is the moment you break your fast.

So when I built Tunisia Prayer Times, I gave it one goal: the same minutes as the official tables. Not close. The same.

Who decides the official time?

In Tunisia, the official prayer tables and the Ramadan imsakiya come from the National Institute of Meteorology (INM, meteo.tn). Their site gives the times for every governorate and delegation. It doesn’t say how they are worked out.

There are several well-known methods, and they differ in small ways: how far below the horizon the sun must be for dawn, how long a shadow means Asr, how many minutes are added for safety. So I took the INM’s own numbers and worked back to the rules that produce them.

The rules, worked back

This is what came out:

  • Fajr and Isha: the sun 18° below the horizon
  • Dhuhr: true noon + 7 minutes
  • Asr: a shadow as long as the object plus its noon shadow (factor 1, the Maliki school)
  • Maghrib: sunset + 2 minutes
  • Imsak: Fajr − 10 minutes
  • Time zone: UTC+1 all year, since Tunisia has no summer time

Some Tunisian news sites print Dhuhr only 1 or 2 minutes after noon. The INM tables, and the app, put it 7 minutes after.

Two smaller details turned out to matter just as much.

The height of the town. From a high place you see the sun a little longer, so dawn comes a bit earlier and sunset a bit later. The INM tables include this: Le Kef and Kasserine get Maghrib about 4–5 minutes later than a town at sea level would. I don’t have the INM’s exact heights, so for each of the 24 governorate seats I found the one small extra angle that makes the numbers match. Kairouan and Sidi Bouzid needed a separate value for sunset only; that is how their official tables are.

When the sun is measured. The INM takes the sun’s position once a day for Dhuhr and Asr, and at the moment itself for dawn, sunset and night. Doing exactly the same gives exactly their minutes.

The maths runs on the phone

Nothing is downloaded when you open the app. The phone works out where the sun is with the NOAA solar formulas (based on Jean Meeus’ Astronomical Algorithms), then finds when it reaches each height, then applies the Tunisian rules above.

That means no server, no account and no trackers. You can add it to your home screen, and it works with no connection at all. It speaks Arabic (right to left), English and French.

Checking it against the official tables

I saved the INM’s official times so the tests check them on every run: 1,560 times in all.

Check Times Same minute 1 minute off
Calibration set: 24 cities, 8 dates 960 957 3
New dates, never used to fit anything 360 352 8
Ramadan 1447 imsakiya, never used to fit anything 240 235 5

So 1,544 of 1,560 are the same minute, and the other 16 are one minute off. None is ever more than one minute off. The misses happen when the true time falls very close to a half minute, where a tiny difference in the sun formulas flips the rounding.

The Ramadan tables matter most here, because they were never used to tune anything. They are a fair test, and they pass.

Close is easy. The same minute meant finding the exact rules.

Ramadan and the Hijri date

In Ramadan, the app switches to a Ramadan card by itself: a countdown to iftar during the day, a countdown to imsak at night, and the length of today’s fast.

The Hijri date comes from the browser’s own Islamic calendar. But Tunisia starts each month when the new moon is actually seen, so the browser can be a day off. Ramadan 1447 began on 18 February 2026 in the Umm al-Qura calendar, but on 19 February in Tunisia. So Settings has a −1 / 0 / +1 day fix, with one line saying why.

What it doesn’t do

No adhan alerts. A web app can’t reliably show a notification at a set time while it’s closed, unless a server sends it a push message. The browser feature that would have done it offline was dropped. I’d rather have no alert than one that only works some of the time.

A few other limits, said plainly:

  • Sunrise isn’t checked, because the INM doesn’t publish it.
  • Only the 24 governorate seats are checked.
  • My location uses your exact spot, and borrows a nearby seat’s height fix if one is within 30 km. In high places far from one, expect up to a few minutes of difference.

Try it

prayer-times-tn.pages.dev. Pick your governorate, and add it to your home screen if you like.