Easier method (and correct) to calculate Midsommardagen.

svn: r14165
This commit is contained in:
Peter Landgren 2010-01-29 14:28:19 +00:00
parent ba553eeba6
commit 1652fe5382
2 changed files with 1 additions and 16 deletions

View File

@ -411,7 +411,7 @@
<date name="Första Maj" value="*/5/1" type="secular" /> <date name="Första Maj" value="*/5/1" type="secular" />
<date name="Kristi Himmelfärdsdag" type="religious" value="> easter(y)" offset="+39" /> <date name="Kristi Himmelfärdsdag" type="religious" value="> easter(y)" offset="+39" />
<date name="Nationaldag" value="*/6/6" type="secular" /> <date name="Nationaldag" value="*/6/6" type="secular" />
<date name="Midsommardagen" value="> swedish_midsummer_day(y)" type="religious" /> <date name="Midsommardagen" value="*/jun/20" offset="sat" type="religious" />
<date name="Allahelgonadagen" value="*/1/sat/nov" type="religious" /> <date name="Allahelgonadagen" value="*/1/sat/nov" type="religious" />
<date name="Juldagen" value="*/12/25" type="religious" /> <date name="Juldagen" value="*/12/25" type="religious" />
<date name="Annandag Jul" value="*/12/26" type="religious" /> <date name="Annandag Jul" value="*/12/26" type="religious" />

View File

@ -87,21 +87,6 @@ def dst(year, area="us"):
stop = "%d/%d/%d" % (year, 10, (31 - (math.floor(year * 5 / 4) + 1) % 7)) # Oct stop = "%d/%d/%d" % (year, 10, (31 - (math.floor(year * 5 / 4) + 1) % 7)) # Oct
return (start, stop) return (start, stop)
def swedish_midsummer_day(year):
"""
Function for calculating date for Swedish Midsummer Day
It is Saturday in week number 25, which is the third or
forth Saturday in June.
First possible date for third Saturday is June, 15
Last possible date for fourth Saturday is June, 28
In holidays.xml it is called by
<date name="Midsommardagen" value="> swedish_midsummer_day(y)" type="religious" />
"""
for day in range(15,29):
d = datetime.date(year, 6, day)
if (year, 25, 6) == d.isocalendar():
return str(year) + "/6/" + str(day)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# HolidayTable # HolidayTable