2
Copyright (c) 2003 Gustavo Niemeyer <niemeyer@conectiva.com>
4
This module offers extensions to the standard python 2.3+
7
__author__ = "Gustavo Niemeyer <niemeyer@conectiva.com>"
8
__license__ = "PSF License"
12
__all__ = ["easter", "EASTER_JULIAN", "EASTER_ORTHODOX", "EASTER_WESTERN"]
18
def easter(year, method=EASTER_WESTERN):
20
This method was ported from the work done by GM Arts,
21
on top of the algorithm by Claus Tondering, which was
22
based in part on the algorithm of Ouding (1940), as
23
quoted in "Explanatory Supplement to the Astronomical
24
Almanac", P. Kenneth Seidelmann, editor.
26
This algorithm implements three different easter
29
1 - Original calculation in Julian calendar, valid in
31
2 - Original method, with date converted to Gregorian
32
calendar, valid in years 1583 to 4099
33
3 - Revised method, in Gregorian calendar, valid in
34
years 1583 to 4099 as well
36
These methods are represented by the constants:
42
The default method is method 3.
44
More about the algorithm may be found at:
46
http://users.chariot.net.au/~gmarts/eastalg.htm
50
http://www.tondering.dk/claus/calendar.html
54
if not (1 <= method <= 3):
55
raise ValueError, "invalid method"
59
# h - (23 - Epact) mod 30
60
# i - Number of days from March 21 to Paschal Full Moon
61
# j - Weekday for PFM (0=Sunday, etc)
62
# p - Number of days from March 21 to Sunday on or before PFM
63
# (-6 to 28 methods 1 & 3, to 56 for method 2)
64
# e - Extra days to add for method 2 (converting Julian
65
# date to Gregorian date)
75
# Extra dates to convert Julian to Gregorian date
78
e = e+y/100-16-(y/100-16)/4
82
h = (c-c/4-(8*c+13)/25+19*g+15)%30
83
i = h-(h/28)*(1-(h/28)*(29/(h+1))*((21-g)/11))
84
j = (y+y/4+i+2-c+c/4)%7
86
# p can be from -6 to 56 corresponding to dates 22 March to 23 May
87
# (later dates apply to method 2, although 23 May never actually occurs)
89
d = 1+(p+27+(p+6)/40)%31
91
return datetime.date(y,m,d)