praytimess

2.3.3 • Public • Published

PrayTimess

A JavaScript library for calculating prayer times based on location, timezone and date. This library helps you get the prayer timings for various locations around the world.

Installation

You can install the praytimess library via npm:

npm install praytimess

Example Usage

// Import the library
const PrayTimes = require('praytimess');

// Create an instance of PrayTimess
const prayTimes = new PrayTimes();

// Set the calculation method (e.g., Egyptian General Authority of Survey)
prayTimes.setMethod('Egypt');

// Define the location and date
const latitude = 30.0444;  // Cairo, Egypt
const longitude = 31.2357; // Cairo, Egypt
const timezone = +2;       // GMT+2 for Cairo
const dst = 1;             // Daylight Saving Time (0 = no, 1 = yes)
const timeformat = '24h';     // 24-hour format

// Get prayer times
const times = prayTimes.getTimes(new Date(), [latitude, longitude], timezone, dst, timeformat);

console.log("Prayer Times:");
console.log(`Imsak: ${times.imsak}`);
console.log(`Fajr: ${times.fajr}`);
console.log(`Sunrise: ${times.sunrise}`);
console.log(`Dhuhr: ${times.dhuhr}`);
console.log(`Asr: ${times.asr}`);
console.log(`Sunset: ${times.sunset}`);
console.log(`Maghrib: ${times.maghrib}`);
console.log(`Isha: ${times.isha}`);
console.log(`Midnight: ${times.midnight}`);

Time Formats

Here are the available time formats:

Format Description Example
24h 24-hour time format 16:45
12h 12-hour time format 4:45 pm
12hNS 12-hour format with no suffix 4:45
Float Floating point number 16.75

Calculation Methods

Set the calculation method using the setMethod function. Here are available methods:

Method Description
MWL Muslim World League
ISNA Islamic Society of North America
Egypt Egyptian General Authority of Survey
Makkah Umm al-Qura University, Makkah
Karachi University of Islamic Sciences, Karachi
Tehran Institute of Geophysics, University of Tehran
Jafari Shia Ithna Ashari (Ja`fari)

Source Acknowledgment

Source: PrayTimes.org by Hamid Zarrabi-Zadeh.

License

This project is licensed under the ISC License.

Key Components of the README

  • Library Overview: A brief introduction to what the library does.
  • Installation Instructions: A command for installing the library using npm.
  • Example Usage: A code example demonstrating how to use the library effectively, including how to define the location and get prayer times.
  • Source Acknowledgment: Credit to the source of the calculations.

Feel free to customize any part of it to better fit your project or add any additional information!

Package Sidebar

Install

npm i praytimess

Weekly Downloads

5

Version

2.3.3

License

ISC

Unpacked Size

19.2 kB

Total Files

3

Last publish

Collaborators

  • eer50