JSPM

muwaqqit

1.0.5
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 13
  • Score
    100M100P100Q56203F
  • License Apache-2.0 license

A powerful and flexible TypeScript library for calculating Islamic prayer times based on location, with customizable settings.

Package Exports

  • muwaqqit
  • muwaqqit/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (muwaqqit) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Logo

Discord NPM License

Muwaqqit

Muwaqqit is a modern and flexible TypeScript library for fetching Islamic prayer times, full calendars, and Hijri/Gregorian date conversions — powered by the AlAdhan API.

🕌 Built with AlAdhan API
📅 Supports full-month and date-range calendars
🕰️ Works with city/country or GPS coordinates
🗓️ Converts between Gregorian ↔ Hijri

🔥 Features

  • 🌍 Fetch times by city/country or latitude/longitude
  • 🕰️ Retrieve daily prayer times
  • 📅 Retrieve monthly prayer calendar
  • 📆 Retrieve prayer times for a custom date range
  • 🗓️ Convert between Gregorian ↔ Hijri dates
  • 🧮 Choose from multiple calculation methods
  • ⏱️ Choose 12h / 24h / ISO time formats
  • 💡 Written in TypeScript — ready for Node.js, bots & web apps

📦 Installation

npm install muwaqqit

💡 Usage Example

TypeScript (ES Modules)

import { PrayerTimes } from 'muwaqqit';

const pt = new PrayerTimes({
  city: 'Cairo',
  country: 'Egypt',
  method: 5, // Egyptian General Authority of Survey
  format: '12h',
});

// 1️⃣ Today's prayer times
const today = await pt.getTimes(new Date());
console.table(today);

// 2️⃣ Full month calendar
const month = await pt.getMonth(10, 2025);
month.forEach(day => {
  console.log(`${day.date.readable} → Fajr: ${day.timings.Fajr}, Dhuhr: ${day.timings.Dhuhr}, Asr: ${day.timings.Asr}, Maghrib: ${day.timings.Maghrib}, Isha: ${day.timings.Isha}`);
});

// 3️⃣ Date range (1–7 Oct 2025)
const range = await pt.getRange('01-10-2025', '07-10-2025');
range.forEach(day => console.log(day.date.readable, day.timings));

// 4️⃣ Gregorian → Hijri
const hijri = await pt.toHijri('23-10-2025');
console.table(hijri);

// 5️⃣ Hijri → Gregorian
const gregorian = await pt.toGregorian('20-04-1447');
console.table(gregorian);

JavaScript (CommonJS)

const { PrayerTimes } = require('muwaqqit');

const pt = new PrayerTimes({
  city: 'Cairo',
  country: 'Egypt',
  method: 5,
  format: '24h',
});

(async () => {
  const times = await pt.getTimes(new Date());
  console.log("Today's Prayer Times:", times);
})();

🧠 API Reference

new PrayerTimes(options)

Option Type Required Description
city string City name (required if not using latitude)
country string Country name (required if not using latitude)
latitude number Decimal latitude (required if not using city)
longitude number Decimal longitude (required if not using city)
method number Calculation method (default = 2)
format "12h" | "24h" | "iso" Output time format (default = "24h")
timezone string Optional timezone override

🧩 Methods

Method Description
getTimes(date: Date) Get daily prayer times for a specific date
getMonth(month: number, year: number) Get full calendar for a month
getRange(start: string, end: string) Get prayer times for a custom date range (e.g., "01-10-2025", "07-10-2025")
toHijri(date: string) Convert Gregorian date to Hijri
toGregorian(date: string) Convert Hijri date to Gregorian

🛠️ Calculation Methods

Based on AlAdhan API:

ID Method
0 Shia Ithna-Ashari
1 University of Islamic Sciences, Karachi
2 Islamic Society of North America
3 Muslim World League
4 Umm Al-Qura University, Makkah
5 Egyptian General Authority of Survey
7 Institute of Geophysics, University of Tehran
12 Union Organization Islamic de France
... (see full list on AlAdhan API docs)

📬 Feedback & Support


📘 License

This project is licensed under the Apache-2.0 License — see the LICENSE file for details.