HP Forums
Phase of the Moon - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: HP Prime Software Library (/forum-15.html)
+--- Thread: Phase of the Moon (/thread-8556.html)



Phase of the Moon - Eddie W. Shore - 06-24-2017 02:30 AM

The following program calculates the approximate phase of the moon. Calculation is based on the following:

1. A base date of August 11, 1999 is used, which was a New Moon.
2. The phases of the moon cycles approximately 29.530588853 days

The results is a phase indicator from 0 to 1.

If the indicator is close to 0 or 1, we have a New Moon.
If the indicator above 0 but below 0.5, it’s the Waxing Crescent Moon.
If the indicator is about or exactly 0.5, we have a Full Moon.
Finally, for an indicator from 0.5 to 1, it’s the Waning Crescent Moon.

Examples:
June 23, 2017: the indicator is 0.991190947
June 24, 2017: the indicator is 0.025054136

Values are approximate.

HP Prime Program: MOONPHASE

Input: MOONPHASE(yyyy.mmdd)
Code:

EXPORT MOONPHASE(d)
BEGIN
// Moon phase
// 0,1: New; 0.5: Full
LOCAL t,p;
t:=DDAYS(1999.0811,d);
p:=FP(t/29.530588853);
RETURN p;
END;

Source: “Moon Phase” voidware.