124 lines
3.1 KiB
Python
124 lines
3.1 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
"""Calculate spacial dates.
|
|
|
|
:Date: 2018-01-15
|
|
|
|
.. module:: date
|
|
:platform: *nix, Windows
|
|
:synopsis: Special dates.
|
|
|
|
.. moduleauthor:: Daniel Weschke <daniel.weschke@directbox.de>
|
|
"""
|
|
from __future__ import division, print_function, unicode_literals
|
|
|
|
def gaußsche_osterformel(year):
|
|
"""Gaußsche Osterformel.
|
|
|
|
:param year: the year to calculate the Easter Sunday
|
|
:type year: int
|
|
|
|
:returns: the day of Easter Sunday as a day in march.
|
|
:rtype: int
|
|
|
|
:ivar X: Das Jahr / year
|
|
:vartype X: int
|
|
:ivar K(X): Die Säkularzahl
|
|
:vartype K(X): int
|
|
:ivar M(X): Die säkulare Mondschaltung
|
|
:vartype M(X): int
|
|
:ivar S(K): Die säkulare Sonnenschaltung
|
|
:vartype S(K): int
|
|
:ivar A(X): Den Mondparameter
|
|
:vartype A(X): int
|
|
:ivar D(A,M): Den Keim für den ersten Vollmond im Frühling
|
|
:vartype D(A,M): int
|
|
:ivar R(D,A): Die kalendarische Korrekturgröße
|
|
:vartype R(D,A): int
|
|
:ivar OG(D,R): Die Ostergrenze
|
|
:vartype OG(D,R): int
|
|
:ivar SZ(X,S): Den ersten Sonntag im März
|
|
:vartype SZ(X,S): int
|
|
:ivar OE(OG,SZ): Die Entfernung des Ostersonntags von der Ostergrenze (Osterentfernung in Tagen)
|
|
:vartype OE(OG,SZ): int
|
|
:ivar OS(OG,OE): Das Datum des Ostersonntags als Märzdatum (32. März = 1. April usw.)
|
|
:vartype OS(OG,OE): int
|
|
|
|
Algorithmus gilt für den Gregorianischen Kalender.
|
|
|
|
source: https://de.wikipedia.org/wiki/Gau%C3%9Fsche_Osterformel
|
|
"""
|
|
x = year
|
|
k = x // 100
|
|
m = 15 + (3*k + 3) // 4 - (8*k + 13) // 25
|
|
s = 2 - (3*k + 3) // 4
|
|
a = x % 19
|
|
d = (19*a + m) % 30
|
|
r = (d + a // 11) // 29
|
|
og = 21 + d - r
|
|
sz = 7 - (x + x // 4 + s) % 7
|
|
oe = 7 - (og - sz) % 7
|
|
os = og + oe
|
|
return os
|
|
|
|
def easter_sunday(year):
|
|
"""Easter Sunday.
|
|
|
|
:param year: the year to calculate the Easter Sunday
|
|
:type year: int
|
|
|
|
:returns: the day of Easter Sunday
|
|
:rtype: datetime.date"""
|
|
import datetime
|
|
march = datetime.date(year, 3, 1)
|
|
day = march + datetime.timedelta(days=gaußsche_osterformel(year))
|
|
return day
|
|
|
|
def easter_friday(year):
|
|
"""Easter Friday.
|
|
|
|
:param year: the year to calculate the Easter Friday
|
|
:type year: int
|
|
|
|
:returns: the day of Easter Friday
|
|
:rtype: datetime.date"""
|
|
import datetime
|
|
day = easter_sunday(year) + datetime.timedelta(days=-2)
|
|
return day
|
|
|
|
def easter_monday(year):
|
|
"""Easter Monday.
|
|
|
|
:param year: the year to calculate the Easter Monday
|
|
:type year: int
|
|
|
|
:returns: the day of Easter Monday
|
|
:rtype: datetime.date"""
|
|
import datetime
|
|
day = easter_sunday(year) + datetime.timedelta(days=+1)
|
|
return day
|
|
|
|
def ascension_of_jesus(year):
|
|
"""Ascension of Jesus.
|
|
|
|
:param year: the year to calculate the ascension of Jesus
|
|
:type year: int
|
|
|
|
:returns: the day of ascension of Jesus
|
|
:rtype: datetime.date"""
|
|
import datetime
|
|
day = easter_sunday(year) + datetime.timedelta(days=+39)
|
|
return day
|
|
|
|
def pentecost(year):
|
|
"""Pentecost.
|
|
|
|
:param year: the year to calculate the Pentecost
|
|
:type year: int
|
|
|
|
:returns: the day of Pentecost
|
|
:rtype: datetime.date"""
|
|
import datetime
|
|
day = easter_sunday(year) + datetime.timedelta(days=+49)
|
|
return day
|