MCPcopy Create free account
hub / github.com/dateutil/dateutil / easter

Function easter

src/dateutil/easter.py:15–88  ·  view source on GitHub ↗

This method was ported from the work done by GM Arts, on top of the algorithm by Claus Tondering, which was based in part on the algorithm of Ouding (1940), as quoted in "Explanatory Supplement to the Astronomical Almanac", P. Kenneth Seidelmann, editor. This algorithm imp

(year, method=EASTER_WESTERN)

Source from the content-addressed store, hash-verified

13
14
15def easter(year, method=EASTER_WESTERN):
16 """
17 This method was ported from the work done by GM Arts,
18 on top of the algorithm by Claus Tondering, which was
19 based in part on the algorithm of Ouding (1940), as
20 quoted in "Explanatory Supplement to the Astronomical
21 Almanac", P. Kenneth Seidelmann, editor.
22
23 This algorithm implements three different Easter
24 calculation methods:
25
26 1. Original calculation in Julian calendar, valid in
27 dates after 326 AD
28 2. Original method, with date converted to Gregorian
29 calendar, valid in years 1583 to 4099
30 3. Revised method, in Gregorian calendar, valid in
31 years 1583 to 4099 as well
32
33 These methods are represented by the constants:
34
35 * ``EASTER_JULIAN = 1``
36 * ``EASTER_ORTHODOX = 2``
37 * ``EASTER_WESTERN = 3``
38
39 The default method is method 3.
40
41 More about the algorithm may be found at:
42
43 `GM Arts: Easter Algorithms <http://www.gmarts.org/index.php?go=415>`_
44
45 and
46
47 `The Calendar FAQ: Easter <https://www.tondering.dk/claus/cal/easter.php>`_
48
49 """
50
51 if not (1 <= method <= 3):
52 raise ValueError("invalid method")
53
54 # g - Golden year - 1
55 # c - Century
56 # h - (23 - Epact) mod 30
57 # i - Number of days from March 21 to Paschal Full Moon
58 # j - Weekday for PFM (0=Sunday, etc)
59 # p - Number of days from March 21 to Sunday on or before PFM
60 # (-6 to 28 methods 1 & 3, to 56 for method 2)
61 # e - Extra days to add for method 2 (converting Julian
62 # date to Gregorian date)
63
64 y = year
65 g = y % 19
66 e = 0
67 if method < 3:
68 # Old method
69 i = (19*g + 15) % 30
70 j = (y + y//4 + i) % 7
71 if method == 2:
72 # Extra dates to convert Julian to Gregorian date

Callers 4

test_easter_westernFunction · 0.90
test_easter_orthodoxFunction · 0.90
test_easter_julianFunction · 0.90
test_easter_bad_methodFunction · 0.90

Calls

no outgoing calls

Tested by 4

test_easter_westernFunction · 0.72
test_easter_orthodoxFunction · 0.72
test_easter_julianFunction · 0.72
test_easter_bad_methodFunction · 0.72