Renamed isodow to dow

svn: r14170
This commit is contained in:
Doug Blank 2010-01-29 21:56:13 +00:00
parent 07fac74e8f
commit 27c20ccaeb
2 changed files with 14 additions and 14 deletions

View File

@ -410,8 +410,8 @@
</country> </country>
<country name="England"> <country name="England">
<date name="New Year's Day" value="*/1/1" type="National" /> <date name="New Year's Day" value="*/1/1" type="National" />
<date name="Bank Holiday" value="*/1/1" offset="+1" if="isodow(y, m, d) == 7" type="national" /> <date name="Bank Holiday" value="*/1/1" offset="+1" if="dow(y, m, d) == 7" type="national" />
<date name="Bank Holiday" value="*/1/1" offset="+2" if="isodow(y, m, d) == 6" type="national" /> <date name="Bank Holiday" value="*/1/1" offset="+2" if="dow(y, m, d) == 6" type="national" />
<date name="Good Friday" value="> easter(y)" offset="-2" 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="Easter Monday" value="> easter(y)" offset="+1" type="National" />
<date name="May Bank Holiday" value="*/1/mon/may" type="National" /> <date name="May Bank Holiday" value="*/1/mon/may" type="National" />
@ -421,8 +421,8 @@
<date name="Summer Bank Holiday" value="*/-1/mon/aug" type="National" /> <date name="Summer Bank Holiday" value="*/-1/mon/aug" type="National" />
<date name="Christmas Day" value="*/dec/25" type="national" /> <date name="Christmas Day" value="*/dec/25" type="national" />
<date name="Boxing Day" value="*/dec/26" type="national" /> <date name="Boxing Day" value="*/dec/26" type="national" />
<date name="Bank Holiday" value="*/dec/25" offset="+2" if="isodow(y, m, d) > 5" type="national" /> <date name="Bank Holiday" value="*/dec/25" offset="+2" if="dow(y, m, d) > 5" type="national" />
<date name="Bank Holiday" value="*/dec/26" offset="+2" if="isodow(y, m, d) > 5" type="national" /> <date name="Bank Holiday" value="*/dec/26" offset="+2" if="dow(y, m, d) > 5" type="national" />
<date name="BST starts" value="*/-1/sun/mar" type="Informational" /> <date name="BST starts" value="*/-1/sun/mar" type="Informational" />
<date name="BST ends" value="*/-1/sun/oct" type="Informational" /> <date name="BST ends" value="*/-1/sun/oct" type="Informational" />
<date name="Valentine's Day" value="*/2/14" type="Secular" /> <date name="Valentine's Day" value="*/2/14" type="Secular" />

View File

@ -87,7 +87,7 @@ 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 isodow(y, m, d): def dow(y, m, d):
""" Return the ISO day of week for the given year, month and day. """ """ Return the ISO day of week for the given year, month and day. """
return datetime.date(y, m, d).isoweekday() return datetime.date(y, m, d).isoweekday()
@ -327,17 +327,17 @@ class _Holidays:
print "%s's in %d %d..." % (dayname, month, year) print "%s's in %d %d..." % (dayname, month, year)
retval = [0] retval = [0]
dow = self.DAYS.index(dayname) day_of_week = self.DAYS.index(dayname)
for day in range(1, 32): for day in range(1, 32):
try: try:
date = datetime.date(year, month, day) date = datetime.date(year, month, day)
except ValueError: except ValueError:
continue continue
if date.weekday() == dow: if date.weekday() == day_of_week:
retval.append(day) retval.append(day)
if self.debug: if self.debug:
print "dow=", dow, "days=", retval print "day_of_week=", day_of_week, "days=", retval
return retval return retval
@ -421,23 +421,23 @@ class _Holidays:
if offset == "workday": if offset == "workday":
# next workday you come to, including this one # next workday you come to, including this one
dow = self.WORKDAY day_of_week = self.WORKDAY
ordinal = ndate.toordinal() ordinal = ndate.toordinal()
while ndate.fromordinal(ordinal).weekday() not in dow: while ndate.fromordinal(ordinal).weekday() not in day_of_week:
ordinal += direction ordinal += direction
ndate = ndate.fromordinal(ordinal) ndate = ndate.fromordinal(ordinal)
elif offset == "weekend": elif offset == "weekend":
# next weekend you come to, including this one # next weekend you come to, including this one
dow = self.WEEKEND day_of_week = self.WEEKEND
ordinal = ndate.toordinal() ordinal = ndate.toordinal()
while ndate.fromordinal(ordinal).weekday() not in dow: while ndate.fromordinal(ordinal).weekday() not in day_of_week:
ordinal += direction ordinal += direction
ndate = ndate.fromordinal(ordinal) ndate = ndate.fromordinal(ordinal)
elif offset in self.DAYS: elif offset in self.DAYS:
# next tuesday you come to, including this one # next tuesday you come to, including this one
dow = self.DAYS.index(offset) day_of_week = self.DAYS.index(offset)
ordinal = ndate.toordinal() ordinal = ndate.toordinal()
while ndate.fromordinal(ordinal).weekday() != dow: while ndate.fromordinal(ordinal).weekday() != day_of_week:
ordinal += direction ordinal += direction
ndate = ndate.fromordinal(ordinal) ndate = ndate.fromordinal(ordinal)