@alighamdan/prayertimes
v1.0.0
Published
get real times of salah with its end time
Downloads
29
Maintainers
Readme
Prayer Times
A TypeScript library for calculating Islamic prayer times based on geographic coordinates using the SunCalc library.
Features
- Calculates daily Islamic prayer times (Fajr, Doha, Duhr, Asr, Maghrib, Isha)
- Includes Last Third of Night calculation
- Location-based calculations using latitude/longitude
- Returns precise start and end times for each prayer period
Installation
npm install @alighamdan/prayertimes
yarn add @alighamdan/prayertimes
pnpm install @alighamdan/prayertimesUsage
import prayerTimes from "@alighamdan/prayertimes";
// Calculate prayer times for a specific date and location
const times = prayerTimes(
new Date(), // Date
lat, // Latitude
long, // Longitude
);
// Access individual prayer times
console.log(times.fajr.start);
console.log(times.fajr.end);API
prayerTimes(date, latitude, longitude)
Parameters:
date: Date object for which to calculate prayer timeslatitude: Geographic latitude coordinatelongitude: Geographic longitude coordinate
Returns: An object containing the following prayer periods:
| Prayer | Description |
| ------------------ | -------------------------------------------------------------------------------------- |
| fajr | Dawn prayer (starts at Fajr, ends at Sunrise) |
| doha | Forenoon prayer window (Sunrise + 15min to Duhr - 10min) |
| duhr | Midday prayer (starts at Solar Noon, ends at Asr) |
| asr | Afternoon prayer (calculated using shadow length method) |
| maghrib | Sunset prayer (starts at Sunset, ends at Nautical Dusk) |
| isha | Night prayer (starts at Nautical Dusk, ends at midpoint between Maghrib and next Fajr) |
| lastThirdOfNight | Special time for voluntary prayers (starts 2/3 through the night, ends at next Fajr) |
Each prayer object contains:
start: Date when the prayer period beginsend: Date when the prayer period ends
Calculation Method
- Fajr angle: -14.5°
- Asr: Calculated using shadow length method based on object height and sun angle at Duhr
- Isha: Midpoint between Maghrib and the next day's Fajr
- Last Third of Night: Last third of the night period (Maghrib to next Fajr)
Tech Stack
- TypeScript
- SunCalc (solar position calculations)
- Node.js
License
All rights are for muslims
