#! /usr/bin/python import datetime def ThirdSunFeb(year): d1 = datetime.date(year,2,1) diff = 14 if d1.weekday() != 6: diff = 6 - d1.weekday() + 14 return d1 + datetime.timedelta(diff) print "Easter Carnival Retdst" for a in range(2009,2039): # Easter Calculation # "Gabriel Zucco Tau" # J.-M.Oudin (1940) # "Explanatory Supplement to the Astronomical Almanac, ed. P.K. Seidelmann (1992)" c = a/100 n = a - 19*(a/19) k = (c - 17)/25 i = c - c/4 - (c-k)/3 +19*n + 15 i = i - 30*(i/30) i = i - (i/28)*(1-(1/28)*(29/(i+1))*((21-n)/11)) j = a + a/4 + i + 2 - c + c/4 j = j - 7*(j/7) l = i - j m = 3 + (l+40)/44 d = l + 28 - 31*(m/4) easter = datetime.date(a,m,d) # Carnival Sunday is seven weeks before easter carnival = easter - datetime.timedelta(7*7) tsf = ThirdSunFeb(a) retdst = tsf if tsf == carnival: # Exception add a week retdst = tsf + datetime.timedelta(7) print easter, carnival, retdst, "*" else: print easter, carnival, retdst