diff options
author | Walter Dörwald <walter@livinglogic.de> | 2006-04-03 15:24:49 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2006-04-03 15:24:49 (GMT) |
commit | 2a1b4a69b76f866400611287cba9016a519322e3 (patch) | |
tree | 90868169d132ad2d07ea4c2bac4261ec1d8e78fe /Lib/calendar.py | |
parent | 72d84af401727711170a605ae5c82596f514f84e (diff) | |
download | cpython-2a1b4a69b76f866400611287cba9016a519322e3.zip cpython-2a1b4a69b76f866400611287cba9016a519322e3.tar.gz cpython-2a1b4a69b76f866400611287cba9016a519322e3.tar.bz2 |
For backwards compatibility reasons the global function
setfirstweekday() still needs to do a range check.
Diffstat (limited to 'Lib/calendar.py')
-rw-r--r-- | Lib/calendar.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Lib/calendar.py b/Lib/calendar.py index 4965773..723bb3c 100644 --- a/Lib/calendar.py +++ b/Lib/calendar.py @@ -132,9 +132,10 @@ class Calendar(object): def getfirstweekday(self): return self._firstweekday % 7 - + def setfirstweekday(self, firstweekday): self._firstweekday = firstweekday + firstweekday = property(getfirstweekday, setfirstweekday) def iterweekdays(self): @@ -159,7 +160,7 @@ class Calendar(object): while True: yield date date += oneday - if date.month != month and date.weekday() == self.firstweekday%7: + if date.month != month and date.weekday() == self.firstweekday: break def itermonthdays2(self, year, month): @@ -567,7 +568,12 @@ class LocaleHTMLCalendar(HTMLCalendar): c = TextCalendar() firstweekday = c.getfirstweekday -setfirstweekday = c.setfirstweekday + +def setfirstweekday(firstweekday): + if not MONDAY <= firstweekday <= SUNDAY: + raise IllegalWeekdayError(firstweekday) + c.firstweekday = firstweekday + monthcalendar = c.monthdayscalendar prweek = c.prweek week = c.formatweek |