JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q46296F
  • License ISC

Prayer times calculator using nrel-spa and custom formula for Fajr and Isha angles (as well as traditional static angle methods in the All function)

Package Exports

  • pray-calc
  • pray-calc/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 (pray-calc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pray-calc

Prayer times calculator using nrel-spa and custom formula for Fajr and Isha angles (as well as traditional static angle methods in the All function).

Installation

npm install pray-calc

Usage

Example of using pray-calc to get prayer times:

const { getTimes, calcTimesAll } = require('pray-calc');

const date = new Date();

/* NYC - minimum params
const city = "New York"
const lat = 40.7128;
const lng = -74.006;
const tz = null
const elevation = null
const temperature = null
const pressure = null
*/

// Jakarta - all params
const city = "Jakarta"
const lat = -6.2088
const lng = 106.8456
const tz = 7
const elevation = 18
const temperature = 26.56
const pressure = 1017

// Get results
const get = getTimes(date, lat, lng); // minimal args
const calc = calcTimesAll(date, lat, lng, tz, elevation, temperature, pressure);

// Print results
console.log(`\nTest: ${city} with current Date():\n`)
console.log("getTimes =", get, "\n");
console.log("calcTimesAll =", calc, "\n");

Exported functions include getTimes, calcTimes, getTimesAll, calcTimesAll where the "get" functions return fractal or decimal times directly from the source nrel-spa calculator and the "calc" functions return formatted times in HH:MM:SS.sss format. The functions will give results including our custom angle but the "All" functions will include a methods key with all traditional static angle methods (Muslim World League, Egyptian General Authority of Survey, ISNA, etc.) included as well for their Fajr and Isha times.

Additionally we included the function "getMoon" which takes only the date object and an optional "accuracy=false" if you wish to avoid the Earth to Sun Distance calculation. The result back will give you fraction:, phase, and angle. This can assist in calculating the moon's illumination at specific times such as after Maghrib in a location's timezone to know the possibility of seeing the moon.

Parameters:

  • date: Javascript Date object for the date to calculate prayer times for.
  • lat: Latitude of the location.
  • lng: Longitude of the location.
  • elevation: Elevation in meters (optional, default 50).
  • temperature: Temperature in Celsius (optional, default 15).
  • pressure: Atmospheric pressure in millibars (optional, default 1013.25).

Contributing

Contributions are welcome!

License

ISC License