Get the latest tech news
Show HN: Moon Phase Algorithms for C, Lua, Awk, JavaScript, etc.
A collection of impls to get the current moon phase - oliverkwebb/moonphase
These functions take a time as an input (usually in unix epoch seconds or the languages official way of doing time), and return the "age" of the moon in radians, such that(1-cos(x))/2 returns the illuminated fraction of the moons surface, this indirection is needed because across a full cycle, the same illuminated percent appears more than once, the first and third quarter are a good example. All implementations contain test cases showing how to get the illuminated fraction and percent using the code. All these snippets are based off the algorithm in moontool, a GUI program made in the 80s by John Walker, which based its algorithms off the book Practical Astronomy With Your Calculator.
Or read this on Hacker News