Skip to content

Instantly share code, notes, and snippets.

@eddymul
Created April 8, 2013 18:33
Show Gist options
  • Save eddymul/5339276 to your computer and use it in GitHub Desktop.
Save eddymul/5339276 to your computer and use it in GitHub Desktop.
""" The angel of the Lord declared unto Mary
and she conceived of the Holy Spirit.
Behold, the handmaid of the Lord
Be it done unto me according to Thy word.
And the Word was made flesh
and dwelt among us."""
from datetime import *
def get_annunciation_date(year):
"""
>>> get_annunciation_date(2013)
datetime.date(2013, 4, 8)
"""
christmas = date(year, month=12, day=25)
annunciation = date(year, month=christmas.month-9, day=christmas.day)
while is_holy_week(annunciation) or is_easter_octave(annunciation):
annunciation += timedelta(days=1)
# the definitions of is_holy_week and is_easter_octave are left
# as an exercise to the reader.
# There might be other rules. Here be bugs and dragons...
return annunciation
def is_holy_week(given_date):
easter = date(2013, 3, 31)
return (easter - timedelta(days=7)) <= given_date <= easter
def is_easter_octave(given_date):
easter = date(2013, 3, 31)
return easter <= given_date <= (easter + timedelta(days=7))
if __name__ == '__main__':
print(get_annunciation_date(2013))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment