Created
April 2, 2019 16:54
-
-
Save surgicalmaskman/593c5f0de5a88c0d05e831a38bbf098d to your computer and use it in GitHub Desktop.
復活祭の日付を計算する python プログラム
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
import datetime | |
year = datetime.date.today().year | |
for year in range(year, 2100): | |
a = year % 19 | |
b = year % 4 | |
c = year % 7 | |
d = ((19 * a) + 24) % 30 | |
e = ((2 * b) + (4 * c) + (6 * d) + 5) % 7 | |
if (d + e) < 10: | |
month = 3 | |
day = d + e + 22 | |
else: | |
month = 4 | |
day = d + e - 9 | |
if day == 26: | |
day = 19 | |
else: | |
if day == 25 and d == 28 and e == 6 and a > 10: | |
day = 18 | |
else: | |
day = d + e - 9 | |
print("{}年の復活祭は{}月{:2d}日。".format(year, month, day)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
なお, 計算には https://ja.wikipedia.org/w/index.php?oldid=69600626 に掲出されている「ガウスのアルゴリズム」とされるものを使用した。