BenMakesGames.MoonMath
is a small library that adds extensions to DateTime
and DateTimeOffset
to calculate the phase of the Moon.
dotnet add package BenMakesGames.MoonMath
using BenMakesGames.MoonMath;
Computes The Moon's "age" - the number of Earth days since the last new moon. Ranges from 0 to ~29.53.
var now = DateTimeOffset.Now;
Console.WriteLine($"It has been {now.GetMoonAge()} days since the last new moon.");
Returns a MoonPhase
indicating the current phase of the Moon. MoonPhase
has the following values:
NewMoon
WaxingCrescent
FirstQuarter
WaxingGibbous
FullMoon
WaningGibbous
ThirdQuarter
WaningCrescent
var now = DateTimeOffset.Now;
var moonPhase = now.GetMoonPhase();
Same as DateTimeOffset.GetMoonAge
, but for DateTime
s.
Same as DateTimeOffset.GetMoonPhase
, but for DateTime
s.
Returns the emoji for the given MoonPhase
:
- 🌑
NewMoon
- 🌒
WaxingCrescent
- 🌓
FirstQuarter
- 🌔
WaxingGibbous
- 🌕
FullMoon
- 🌖
WaningGibbous
- 🌗
ThirdQuarter
- 🌘
WaningCrescent
var now = DateTimeOffset.Now;
Console.WriteLine(now.GetMoonPhase().ToEmoji());