From 0e757dfc0dbf7befdd0284f58fcea332a70fa8d7 Mon Sep 17 00:00:00 2001 From: Don Cross Date: Thu, 18 Apr 2019 13:05:29 -0400 Subject: [PATCH] Skip 6 days (instead of 1) to find next moon quarter. This should help find the next quarter slightly more efficiently because it will provide a more accurate estimate of the next quarter. --- generate/run | 3 ++- generate/template/astronomy.js | 7 +++---- generate/verify_clean | 2 +- source/js/astronomy.js | 7 +++---- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/generate/run b/generate/run index 8543cb22..87c0dff1 100755 --- a/generate/run +++ b/generate/run @@ -61,8 +61,9 @@ rm -f output/vsop_*.txt temp/* ./generate all || Fail "Could not generate target code." echo "" -echo "Validating JavaScript code." +echo "Running astro_check." node astro_check.js > temp/check.txt || Fail "Problem running JavaScript unit test." +echo "Verifying astro_check output." ./generate check temp/check.txt || Fail "Verification failure for JavaScript unit test output." echo "" diff --git a/generate/template/astronomy.js b/generate/template/astronomy.js index 6e5439f8..62373e81 100644 --- a/generate/template/astronomy.js +++ b/generate/template/astronomy.js @@ -1279,13 +1279,12 @@ Astronomy.SearchMoonQuarter = function(dateStart) { let quarterStart = Math.floor(phaseStart / 90); let quarter = (quarterStart + 1) % 4; let time = Astronomy.SearchMoonPhase(90 * quarter, dateStart, 10); - if (!time) return null; - return { quarter:quarter, time:time }; + return time && { quarter:quarter, time:time }; } Astronomy.NextMoonQuarter = function(mq) { - // Skip one day past the previous found moon quarter to find the next one. - let date = new Date(mq.time.date.getTime() + millis_per_day); + // Skip 6 days past the previous found moon quarter to find the next one. + let date = new Date(mq.time.date.getTime() + 6*millis_per_day); return Astronomy.SearchMoonQuarter(date); } diff --git a/generate/verify_clean b/generate/verify_clean index e654540d..96dcecbd 100755 --- a/generate/verify_clean +++ b/generate/verify_clean @@ -5,4 +5,4 @@ if ! git diff-files --quiet --ignore-submodules; then exit 1 fi echo "verify_clean: OK" -exit 0 \ No newline at end of file +exit 0 diff --git a/source/js/astronomy.js b/source/js/astronomy.js index a410178f..9b4e3ccb 100644 --- a/source/js/astronomy.js +++ b/source/js/astronomy.js @@ -2116,13 +2116,12 @@ Astronomy.SearchMoonQuarter = function(dateStart) { let quarterStart = Math.floor(phaseStart / 90); let quarter = (quarterStart + 1) % 4; let time = Astronomy.SearchMoonPhase(90 * quarter, dateStart, 10); - if (!time) return null; - return { quarter:quarter, time:time }; + return time && { quarter:quarter, time:time }; } Astronomy.NextMoonQuarter = function(mq) { - // Skip one day past the previous found moon quarter to find the next one. - let date = new Date(mq.time.date.getTime() + millis_per_day); + // Skip 6 days past the previous found moon quarter to find the next one. + let date = new Date(mq.time.date.getTime() + 6*millis_per_day); return Astronomy.SearchMoonQuarter(date); }