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.
This commit is contained in:
Don Cross
2019-04-18 13:05:29 -04:00
parent da07dda836
commit 0e757dfc0d
4 changed files with 9 additions and 10 deletions

View File

@@ -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 ""

View File

@@ -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);
}

View File

@@ -5,4 +5,4 @@ if ! git diff-files --quiet --ignore-submodules; then
exit 1
fi
echo "verify_clean: OK"
exit 0
exit 0

View File

@@ -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);
}