From 0f6b4046f3cd6310ab5287f65d8d1d9331e2adb0 Mon Sep 17 00:00:00 2001 From: Ali Camarata Date: Sun, 12 Nov 2023 11:26:19 +0700 Subject: [PATCH] added getMoon --- README.md | 4 +++- getMoon.js | 6 +++++- index.js | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b89ef90..73f0345 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/getMoon.js b/getMoon.js index 1f24bc6..efb7df2 100644 --- a/getMoon.js +++ b/getMoon.js @@ -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 +}; diff --git a/index.js b/index.js index adf216b..e9a2d48 100644 --- a/index.js +++ b/index.js @@ -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,