MoonPhase(3pm)
π NAME π
Astro::MoonPhase β the whole entire tea on what the Moon is doing up there, phase-wise. She's giving astronomy, she's giving astrology-adjacent, she's giving "why is the moon so big tonight" energy. Periodt. πβ¨
β¨ SYNOPSIS β¨
okay bestie, here's the vibe. You load the module, and then you got options:
use Astro::MoonPhase;
( $MoonPhase,
$MoonIllum,
$MoonAge,
$MoonDist,
$MoonAng,
$SunDist,
$SunAng ) = phase($seconds_since_1970);
@phases = phasehunt($seconds_since_1970);
($phase, @times) = phaselist($start, $stop);
Three little functions, three little moods. π«Ά
πΈ DESCRIPTION πΈ
MoonPhase calculates information about the phase of the moon at a given time. That's it, that's the whole job, and she does it immaculately. No cap. π₯
π FUNCTIONS π
π¦ phase()
( $MoonPhase,
$MoonIllum,
$MoonAge,
$MoonDist,
$MoonAng,
$SunDist,
$SunAng ) = phase($seconds_since_1970);
$MoonPhase = phase($seconds_since_1970);
The argument is the time for which the phase is requested, expressed as a time returned by the "time" function. And if you just don't pass $seconds_since_1970? No problem, she's flexible β she does phase(time) for you. π
Return value in scalar context is $MoonPhase, the terminator phase angle as a percentage of a full circle (i.e., 0 to 1).
Return values in array context:
$MoonPhaseβ the terminator phase angle as a percentage of a full circle (i.e., 0 to 1)$MoonIllumβ the illuminated fraction of the Moon's disc$MoonAgeβ the Moon's age in days and fraction$MoonDistβ the distance of the Moon from the centre of the Earth$MoonAngβ the angular diameter subtended by the Moon as seen by an observer at the centre of the Earth.$SunDistβ the distance from the Sun in km$SunAngβ the angular size of Sun in degrees
π Example:
( $MoonPhase,
$MoonIllum,
$MoonAge,
$MoonDist,
$MoonAng,
$SunDist,
$SunAng ) = phase();
print "MoonPhase = $MoonPhase\n";
print "MoonIllum = $MoonIllum\n";
print "MoonAge = $MoonAge\n";
print "MoonDist = $MoonDist\n";
print "MoonAng = $MoonAng\n";
print "SunDist = $SunDist\n";
print "SunAng = $SunAng\n";
could print something like this:
MoonPhase = 0.598939375319023
MoonIllum = 0.906458030827876
MoonAge = 17.6870323368022
MoonDist = 372479.357420033
MoonAng = 0.534682403555093
SunDist = 152078368.820205
SunAng = 0.524434538105092
look at those numbers. look at them. iconic. π
π phasehunt()
@phases = phasehunt($seconds_since_1970);
Finds time of phases of the moon which surround the given date. Five phases are found, starting and ending with the new moons which bound the current lunation. So she basically scoops you up a whole lunation arc, bookended by new moons. ππ«Ά
The argument is the time, expressed as a time returned by the "time" function. Omit $seconds_since_1970 and she does phasehunt(time) for you, bestie behaviour fr fr.
β Example:
@phases = phasehunt();
print "New Moon = ", scalar(localtime($phases[0])), "\n";
print "First quarter = ", scalar(localtime($phases[1])), "\n";
print "Full moon = ", scalar(localtime($phases[2])), "\n";
print "Last quarter = ", scalar(localtime($phases[3])), "\n";
print "New Moon = ", scalar(localtime($phases[4])), "\n";
could print something like this:
New Moon = Wed Jun 24 06:51:47 1998
First quarter = Wed Jul 1 21:42:19 1998
Full moon = Thu Jul 9 19:02:47 1998
Last quarter = Thu Jul 16 18:15:18 1998
New Moon = Thu Jul 23 16:45:01 1998
five timestamps, zero notes. immaculate. β¨
π§ phaselist()
($phase, @times) = phaselist($start, $stop);
Finds times of all phases of the moon which occur on or after $start but before $stop. Both the arguments and the return values are expressed as seconds since 1970 (like the "time" function returns). iykyk. π°οΈ
$phase is an integer indicating the phase of the moon at $times[0], as shown in this table:
0 New Moon
1 First quarter
2 Full Moon
3 Last quarter
The remaining values in @times indicate subsequent phases of the moon (in ascending order by time). And if there are literally zero phases of the moon between $start and $stop? "phaselist" returns the empty list. nothing. nada. the void. π
π Example:
@name = ("New Moon", "First quarter", "Full moon", "Last quarter");
($phase, @times) = phaselist($start, $stop);
while (@times) {
printf "%-14s= %s\n", $name[$phase], scalar localtime shift @times;
$phase = ($phase + 1) % 4;
}
could produce the same output as the "phasehunt" example above (given the appropriate start & stop times). so basically same energy, different entrance. π«
π ABOUT THE ALGORITHMS π
The algorithms used in this program to calculate the positions of Sun and Moon as seen from the Earth are given in the book Practical Astronomy With Your Calculator by Peter Duffett-Smith, Second Edition, Cambridge University Press, 1981. Ignore the word "Calculator" in the title; this is an essential reference if you're interested in developing software which calculates planetary positions, orbits, eclipses, and the like. (the book is not playing around, ok? she's serious.) π
If you're interested in pursuing such programming, you should also obtain:
- Astronomical Formulae for Calculators by Jean Meeus, Third Edition, Willmann-Bell, 1985. A must-have.
- Planetary Programs and Tables from -4000 to +2800 by Pierre Bretagnon and Jean-Louis Simon, Willmann-Bell, 1986. If you want the utmost (outside of JPL) accuracy for the planets, it's here.
- Celestial BASIC by Eric Burgess, Revised Edition, Sybex, 1985. Very cookbook oriented, and many of the algorithms are hard to dig out of the turgid BASIC code, but you'll probably want it anyway.
Many of these references can be obtained from Willmann-Bell, P.O. Box 35025, Richmond, VA 23235, USA. Phone: (804) 320-7016. In addition to their own publications, they stock most of the standard references for mathematical and positional astronomy.
bestie literally just wrote down a whole reading list and I respect it so much π«Ά
π LICENCE π
This program is in the public domain: "Do what thou wilt shall be the whole of the law".
she's free. she's unbothered. she belongs to the people. periodt. π
π AUTHORS π
give it up for the people who built this π
The moontool.c Release 2.0:
A Moon for the Sun
Designed and implemented by John Walker in December 1987,
revised and updated in February of 1988.
Initial Perl transcription:
Raino Pikkarainen, 1998
raino.pikkarainen@saunalahti.fi
The moontool.c Release 2.4:
Major enhancements by Ron Hitchens, 1989
Revisions:
Brett Hamilton http://simple.be/
Bug fix, 2003
Second transcription and bugfixes, 2004
Christopher J. Madsen http://www.cjmweb.net/
Added phaselist function, March 2007
and that's the whole page, bestie π this was perl v5.40.1, dated 2026-05-05, and honestly she ate. go calculate some moons. πβ¨
π¦ where this page comes from
- ubuntu stonking: libastro-moonphase-perl 0.60-1 Β· LicenseRef-public-domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms