How the Moon Tool Calculates the Phase (No API)
People often assume a moon-phase tool must call some astronomy service. Ours does not — it computes everything in your browser from standard orbital formulas.
Sun and moon positions
The tool uses the well-known SunCalc formulas to work out the positions of the sun and moon for the current instant. From the angle between them it derives the illuminated fraction (how much of the disc is lit) and the phase angle (where in the cycle we are), then names the phase. To find the next full and new moon it simply scans that phase value forward hour by hour until it crosses the right point.
Why offline matters
Because it is pure maths, the tool keeps working with no internet connection once loaded, and nothing about your visit is sent anywhere. The moon disc itself is drawn as an SVG: a lit circle, a dark limb, and a terminator ellipse whose width tracks the illuminated fraction. The only time a location is involved is the optional moonrise/moonset, which is also computed locally.
Finding the next full and new moon
Scanning forward hour by hour is deliberately crude, and it is enough: the phase angle changes smoothly, so the first hour in which it crosses the target value brackets the event, and a short refinement inside that hour lands the moment. The synodic month averages about 29.53 days, so the scan never has to look more than roughly 30 days ahead to find both.
Where the accuracy limit sits
SunCalc-style formulas are truncated series: they ignore the smaller periodic terms in the moon's orbit, which is why the illuminated fraction is good to a fraction of a percent and phase moments to a couple of minutes rather than to the second. For picking a stargazing night or a full-moon walk that is far more precision than anyone needs, and it buys an implementation with no network call at all.
See the offline moon calculator in action.
Open the Moon Phase tool