Skip to content

Instantly share code, notes, and snippets.

@oschuett
Last active December 17, 2015 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oschuett/5653243 to your computer and use it in GitHub Desktop.
Save oschuett/5653243 to your computer and use it in GitHub Desktop.
The Sechseläuten is a traditional spring holiday in the Swiss city of Zürich. This python function calculates for a given year the holiday's date.
def sechselaeuten(year):
from datetime import date, timedelta
from dateutil.easter import easter
april_mondays = [date(year,4,d) for d in range(1,31) if date(year,4,d).weekday()==0]
holy_monday = easter(year) - timedelta(days=6)
easter_monday = easter(year) + timedelta(days=1)
if(april_mondays[2].isocalendar()[1] in (17, 18)): # avoid school holidays...
if(april_mondays[1] not in (holy_monday, easter_monday)): #...unless there's s.th. else
return(april_mondays[1])
if(april_mondays[2] == holy_monday): # avoid holy week
return(april_mondays[1])
if(april_mondays[2] == easter_monday): # avoid easter
return(april_mondays[3])
return(april_mondays[2]) # default date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment