By foul moon
Because I know that I will need it...
# Not very accurate, but apperantly good enough for most purposes
# source: http://www.faqs.org/faqs/astronomy/faq/part3/section-15.html
def IsFullMoon(dateToCheck as date):
two_digit_year as decimal = dateToCheck.Year - ((dateToCheck.Year/100)*100)
remainder as decimal = two_digit_year %19
if remainder > 9:
remainder -= 19;
phase as decimal = (remainder * 11) %30
if dateToCheck.Month == 1:
phase+=3
elif dateToCheck.Month == 2:
phase+=4
else:
phase+= dateToCheck.Month
phase+=dateToCheck.Day
if dateToCheck.Year < 2000:
phase -= 4
else:
phase -= 8.3
phase = phase % 30
return 14.5 < phase and phase < 15.5
Expected usage:
if IsFullMoon(DateTime.Now):
raise SqlException("""Transaction (Process ID 179) was deadlocked on lock resources with another
process and has been chosen as the deadlock victim. Rerun the transaction.""")
Update: I am still struggling with the code for WasChickenSacrifised(), will be glad to get suggestions...

Comments
Comment preview