jhurliman / SunMoonCalculator / 0.1.0



Calculate sun position, sunlight phases (times for sunrise, sunset, dusk, etc.), moon position and lunar phase for a given location and time. Based on code from the SunCalc.net project.



timeDate used for calculations. Common date/time formats are accepted such as YYYY-MM-DD and ISO 8601
latLatitude. Valid values range from [-90, 90]
lonLongitude. Valid values range from [-180, 180]


timeInput timestamp used for calculations
sunrisesunrise (top edge of the sun appears on the horizon)
sunrise_endsunrise ends (bottom edge of the sun touches the horizon)
golden_hour_endmorning golden hour (soft light, best time for photography) ends
solar_noonsolar noon (sun is in the highest position)
golden_hourevening golden hour starts
sunset_startsunset starts (bottom edge of the sun touches the horizon)
sunsetsunset (sun disappears below the horizon, evening civil twilight starts)
duskdusk (evening nautical twilight starts)
nautical_dusknautical dusk (evening astronomical twilight starts)
nightnight starts (dark enough for astronomical observations)
nadirnadir (darkest moment of the night, sun is in the lowest position)
night_endnight ends (morning astronomical twilight starts)
nautical_dawnnautical dawn (morning nautical twilight starts)
dawndawn (morning nautical twilight ends, morning civil twilight starts)
sun_altitudesun altitude above the horizon in radians, e.g. 0 at the horizon and PI/2 at the zenith (straight over your head)
sun_azimuthsun azimuth in radians (direction along the horizon, measured from south to west), e.g. 0 is south and Math.PI * 3/4 is northwest
moon_altitudemoon altitude above the horizon in radians
moon_azimuthmoon azimuth in radians
moon_distancedistance to moon in kilometers
moon_parallactic_angleparallactic angle of the moon in radians
moon_fractionilluminated fraction of the moon; varies from 0.0 (new moon) to 1.0 (full moon)
moon_phasemoon phase; varies from 0.0 to 1.0, described below
moon_anglemidpoint angle in radians of the illuminated limb of the moon reckoned eastward from the north point of the disk; the moon is waxing if the angle is negative, and waning if positive
moonrisemoonrise time
moonsetmoonset time
moon_always_uptrue if the moon never rises/sets and is always above the horizon during the day
moon_always_downtrue if the moon is always below the horizon

Moon phase should be interpreted as:

0New Moon
Waxing Crescent
0.25First Quarter
Waxing Gibbous
0.5Full Moon
Waning Gibbous
0.75Last Quarter
Waning Crescent