From d8a6d2f6a8c2a228c86d1d25250083c796e1a070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vlada=20Peri=C4=87?= Date: Thu, 17 Jul 2014 17:22:54 -0700 Subject: [PATCH] 7912: Add julian_easter(y) function to libholiday.py --- gramps/plugins/lib/libholiday.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/gramps/plugins/lib/libholiday.py b/gramps/plugins/lib/libholiday.py index 2d41ad628..1bf0ce320 100644 --- a/gramps/plugins/lib/libholiday.py +++ b/gramps/plugins/lib/libholiday.py @@ -74,6 +74,31 @@ def easter(year): day = l + 28 - 31 * (month / 4) return "%d/%d/%d" % (year, month, day) +def julian_easter(year): + """ + Computes the year/month/day of Eastern Orthodox Easter, given in the + Gregorian calendar. Implements the Jean Meeus algorithm. Valid: 1900-2099. + """ + a = year % 4 + b = year % 7 + c = year % 19 + d = (19*c + 15) % 30 + e = (2*a + 4*b - d + 34) % 7 + month = int(math.floor((d + e + 114) / 31)) + day = ((d + e + 114) % 31) + 1 + + # produced date was in the Julian calendar, add 13 days to it + day = day + 13 + + if month == 3 and day > 31: + day = day - 31 + month = 4 + elif month == 4 and day > 30: + day = day - 30 + month = 5 + + return "%d/%d/%d" % (year, month, day) + def passover(year): """ Returns the date of Passover in a given Gregorian year.