Skip to content

Instantly share code, notes, and snippets.

@mtimkovich
Last active February 20, 2024 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtimkovich/fdbd69440896c8994d2d41af240667c3 to your computer and use it in GitHub Desktop.
Save mtimkovich/fdbd69440896c8994d2d41af240667c3 to your computer and use it in GitHub Desktop.
"Aw man, Tray, look up at the sky. It's a full moon. On the Sabbath." -Werewolf Bar Mitzvah
from datetime import date, timedelta
# http://www.voidware.com/moon_phase.htm
def moon_phase(y, m, d):
"""
0 => new moon
1 => waxing crescent
2 => first quarter
3 => waxing gibbous
4 => full moon
5 => waning gibbous
6 => third quarter
7 => waning crescent
"""
if m < 3:
y -= 1
m += 12
m += 1
c = 365.25 * y
e = 30.6 * m
jd = c + e + d - 694039.09
jd /= 29.53
b = int(jd)
jd -= b
b = jd * 8 + 0.5
b = int(b) & 7
return b
today = date(2024, 1, 1)
friday = today + timedelta((4 - today.weekday()) % 7)
for i in range(52*4):
phase = moon_phase(friday.year, friday.month, friday.day)
if phase == 4:
print(friday)
friday += timedelta(weeks=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment