Path: blob/master/ invest-robot-contest_TinkoffBotTwitch-main/venv/lib/python3.8/site-packages/dateutil/easter.py
7771 views
# -*- coding: utf-8 -*-1"""2This module offers a generic Easter computing method for any given year, using3Western, Orthodox or Julian algorithms.4"""56import datetime78__all__ = ["easter", "EASTER_JULIAN", "EASTER_ORTHODOX", "EASTER_WESTERN"]910EASTER_JULIAN = 111EASTER_ORTHODOX = 212EASTER_WESTERN = 3131415def easter(year, method=EASTER_WESTERN):16"""17This method was ported from the work done by GM Arts,18on top of the algorithm by Claus Tondering, which was19based in part on the algorithm of Ouding (1940), as20quoted in "Explanatory Supplement to the Astronomical21Almanac", P. Kenneth Seidelmann, editor.2223This algorithm implements three different Easter24calculation methods:25261. Original calculation in Julian calendar, valid in27dates after 326 AD282. Original method, with date converted to Gregorian29calendar, valid in years 1583 to 4099303. Revised method, in Gregorian calendar, valid in31years 1583 to 4099 as well3233These methods are represented by the constants:3435* ``EASTER_JULIAN = 1``36* ``EASTER_ORTHODOX = 2``37* ``EASTER_WESTERN = 3``3839The default method is method 3.4041More about the algorithm may be found at:4243`GM Arts: Easter Algorithms <http://www.gmarts.org/index.php?go=415>`_4445and4647`The Calendar FAQ: Easter <https://www.tondering.dk/claus/cal/easter.php>`_4849"""5051if not (1 <= method <= 3):52raise ValueError("invalid method")5354# g - Golden year - 155# c - Century56# h - (23 - Epact) mod 3057# i - Number of days from March 21 to Paschal Full Moon58# j - Weekday for PFM (0=Sunday, etc)59# p - Number of days from March 21 to Sunday on or before PFM60# (-6 to 28 methods 1 & 3, to 56 for method 2)61# e - Extra days to add for method 2 (converting Julian62# date to Gregorian date)6364y = year65g = y % 1966e = 067if method < 3:68# Old method69i = (19*g + 15) % 3070j = (y + y//4 + i) % 771if method == 2:72# Extra dates to convert Julian to Gregorian date73e = 1074if y > 1600:75e = e + y//100 - 16 - (y//100 - 16)//476else:77# New method78c = y//10079h = (c - c//4 - (8*c + 13)//25 + 19*g + 15) % 3080i = h - (h//28)*(1 - (h//28)*(29//(h + 1))*((21 - g)//11))81j = (y + y//4 + i + 2 - c + c//4) % 78283# p can be from -6 to 56 corresponding to dates 22 March to 23 May84# (later dates apply to method 2, although 23 May never actually occurs)85p = i - j + e86d = 1 + (p + 27 + (p + 6)//40) % 3187m = 3 + (p + 26)//3088return datetime.date(int(y), int(m), int(d))899091