Back to articles
Building a Production-Ready Islamic Prayer Times Library in TypeScript

Building a Production-Ready Islamic Prayer Times Library in TypeScript

via Dev.to Webdevabdoartistico

Building a simple clock to calculate the Islamic call to prayer ( Adhan ) seems straightforward at first. Since the timing of the five daily prayers is based entirely on the position of the sun, you just need a bit of astronomy, right? Well, yes. But if you try to build a production app, you quickly realize that astronomy is easy, but geography is hard. In this tutorial, we will look at how to calculate prayer times using TypeScript, investigate the geographical edge cases that break naive implementations, and look at an open-source mapping engine we built to solve them. Step 1: The Basic Calculations (The Easy Part) At the core, you need to calculate solar declination based on a user's latitude and longitude. Instead of recreating NASA-level math from scratch, the brilliant adhan.js library handles the astronomy perfectly. Let's assume we want to get the prayer times for London, UK: import { Coordinates , CalculationMethod , PrayerTimes } from ' adhan ' ; // London, UK Coordinates con

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
2 views

Related Articles