I guess I'm mis-remembering it. Here are some illuminating comments from the code. It uses a public-domain bit of code I found (and can't find online anymore, the links are dead...) that "determines the fraction of the moon's disk that is illuminated at a given time", and also tells if the moon is waxing or waning, for a given Julian date. (Presumably at midnight, but I don't really know. The formula uses a bunch of hard-coded constants that only work at the date-level.) It's based on calculations by Jean Meeus, I think this book
https://www.amazon.com/Astronomical-.../dp/0943396611. I honestly don't understand any of the moon math.
Using that code, my code just divvies the dates up, assigning a moon phase to each date.
// we want the "full moon" to be EXACTLY 3 days. So we find the
// most full day, and declare that day to be full, as well as the day
// before and after it.
// We do the same for the "new moon" and the two quarter-moons, also exactly 3 days.
// the dates that don't have phases yet are the "leftover" phases.
// Their length varies between 3 and 5 days depending on the month
The "leftover" phases are WaxingCrescentMoon, WaxingGibbousMoon, WaningGibbousMoon, and WaningCrescentMoon.