Add ISO day of week function

svn: r14168
This commit is contained in:
Nick Hall 2010-01-29 18:18:08 +00:00
parent 717572d6e3
commit 1348340dc6
2 changed files with 17 additions and 23 deletions

View File

@ -21,11 +21,11 @@
<date name="Ash Wednesday" type="religious" value="> easter(y)" offset="-46" />
<date name="Daylight Saving begins" value="> dst(y)[0]" type="informational" />
<date name="Income Taxes due" value="*/4/15" type="national"
if="date.weekday().__cmp__(4)-1" />
if="date.weekday().__cmp__(4)-1" />
<date name="Income Taxes due" value="*/4/16" type="national"
if="date.weekday() == 0" />
if="date.weekday() == 0" />
<date name="Income Taxes due" value="*/4/17" type="national"
if="date.weekday() == 0" />
if="date.weekday() == 0" />
<date name="Daylight Saving ends" value="> dst(y)[1]" type="informational" />
<date name="Inauguration Day" value="*/1/20" if="(y - 1980) % 4 == 1" type="national" />
@ -409,35 +409,25 @@
<date name="Annandag Jul" value="*/12/26" type="religious" />
</country>
<country name="England">
<date name="New Year's Day" value="2010/1/1" type="National" />
<date name="New Year's Day" value="2011/1/3" type="National" />
<date name="New Year's Day" value="2012/1/2" type="National" />
<date name="Good Friday" value="2010/4/2" type="National" />
<date name="Good Friday" value="2011/4/22" type="National" />
<date name="Good Friday" value="2012/4/6" type="National" />
<date name="Easter Monday" value="2010/4/5" type="National" />
<date name="Easter Monday" value="2011/4/25" type="National" />
<date name="Easter Monday" value="2012/4/9" type="National" />
<date name="New Year's Day" value="*/1/1" offset="workday" type="National" />
<date name="Good Friday" value="> easter(y)" offset="-2" type="National" />
<date name="Easter Monday" value="> easter(y)" offset="+1" type="National" />
<date name="May Bank Holiday" value="*/1/mon/may" type="National" />
<date name="Spring Bank Holiday" value="2010/5/31" type="National" />
<date name="Spring Bank Holiday" value="2011/5/30" type="National" />
<date name="Spring Bank Holiday" value="*/-1/mon/may" if="y != 2012" type="National" />
<date name="Spring Bank Holiday" value="2012/6/4" type="National" />
<date name="Queen's Diamond Jubilee" value="2012/6/5" type="National" />
<date name="Summer Bank Holiday" value="*/-1/mon/aug" type="National" />
<date name="Christmas Day" value="2010/12/27" type="National" />
<date name="Christmas Day" value="2011/12/26" type="National" />
<date name="Christmas Day" value="2012/12/25" type="National" />
<date name="Boxing Day" value="2010/12/28" type="National" />
<date name="Boxing Day" value="2011/12/27" type="National" />
<date name="Boxing Day" value="2012/12/26" type="National" />
<date name="Christmas Day" value="*/dec/25" type="national" />
<date name="Boxing Day" value="*/dec/26" type="national" />
<date name="Holiday in lieu of Christmas Day" value="*/dec/25" offset="+2" if="isodow(y, m, d) > 5" type="national" />
<date name="Holiday in lieu of Boxing Day" value="*/dec/26" offset = "+2" if="isodow(y, m, d) > 5" type="national" />
<date name="BST starts" value="*/-1/sun/mar" type="Informational" />
<date name="BST ends" value="*/-1/sun/oct" type="Informational" />
<date name="Valentine's Day" value="*/2/14" type="Secular" />
<date name="Shrove Tuesday" value="> easter(y)" offset="-47" type="Religious" />
<date name="April Fool's Day" value="*/4/1" type="Secular" />
<date name="St. George's Day" value="*/4/23" type="Secular" />
<date name="Mothering Sunday" value="2010/3/14" type="Secular" />
<date name="Mothering Sunday" value="2011/4/3" type="Secular" />
<date name="Mothering Sunday" value="2012/3/18" type="Secular" />
<date name="Mothering Sunday" value="> easter(y)" offset="-21" type="Secular" />
<date name="Fathers' Day" value="*/3/sun/jun" type="Secular" />
<date name="Halloween" value="*/10/31" type="Secular" />
<date name="Guy Fawkes Night" value="*/11/5" type="Secular" />

View File

@ -87,6 +87,10 @@ def dst(year, area="us"):
stop = "%d/%d/%d" % (year, 10, (31 - (math.floor(year * 5 / 4) + 1) % 7)) # Oct
return (start, stop)
def isodow(y, m, d):
""" Return the ISO day of week for the given year, month and day. """
return datetime.date(y, m, d).isoweekday()
#------------------------------------------------------------------------
#
# HolidayTable