36 lines
941 B
Python
36 lines
941 B
Python
# Calculation how many days to next Easter sunday
|
|
|
|
import sys
|
|
from datetime import date
|
|
|
|
def easter(year):
|
|
a = year % 19
|
|
b = year % 4
|
|
c = year % 7
|
|
k = year // 100
|
|
p = k // 3
|
|
q = k // 4
|
|
M = (15 + k - p - q) % 30
|
|
d = (19*a + M) % 30
|
|
N = (4 + k - q) % 7
|
|
e = (2*b + 4*c + 6*d + N) % 7
|
|
|
|
easter_date = 22 + d + e
|
|
if easter_date > 31:
|
|
return date(year, 4, easter_date - 31)
|
|
else:
|
|
return date(year, 3, easter_date)
|
|
|
|
# Determine Easter date for current year
|
|
easter_current_year = easter(date.today().year)
|
|
days_remaining = (easter_current_year - date.today()).days
|
|
# If it has already passed, determine date for next year
|
|
if days_remaining < 0:
|
|
easter_next_year = easter(date.today().year + 1)
|
|
days_remaining = (easter_next_year - date.today()).days
|
|
|
|
if days_remaining == 0:
|
|
print("juhu, ostersonntag!")
|
|
else:
|
|
print(f"Noch {days_remaining} Tage bis Ostersonntag!")
|