added getMoon

This commit is contained in:
Ali Camarata 2023-11-12 11:26:19 +07:00
parent cf8aa20577
commit 0f6b4046f3
3 changed files with 10 additions and 2 deletions

View file

@ -27,9 +27,11 @@ console.log(prayerTimes);
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: The date for which prayer times are calculated.
- 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).

View file

@ -1,6 +1,6 @@
const { getEarthSunDistance } = require('./getEarthSunDistance');
function getMoon(date, accurate = false) {
function getMoon(date, accurate = true) {
const PI = Math.PI;
const rad = PI / 180;
const e = rad * 23.4397; // obliquity of the Earth
@ -59,3 +59,7 @@ function getMoon(date, accurate = false) {
angle: angle
};
}
module.exports = {
getMoon
};

View file

@ -1,3 +1,4 @@
const { getMoon } = require('./getMoon');
const { getTimes } = require('./getTimes');
const { calcTimes } = require('./calcTimes');
const { getTimesAll } = require('./getTimesAll');
@ -5,6 +6,7 @@ const { calcTimesAll } = require('./calcTimesAll');
module.exports = {
getMoon,
getTimes,
calcTimes,
getTimesAll,