]> granicus.if.org Git - python/commitdiff
For backwards compatibility reasons the global function
authorWalter Dörwald <walter@livinglogic.de>
Mon, 3 Apr 2006 15:24:49 +0000 (15:24 +0000)
committerWalter Dörwald <walter@livinglogic.de>
Mon, 3 Apr 2006 15:24:49 +0000 (15:24 +0000)
setfirstweekday() still needs to do a range check.

Lib/calendar.py

index 4965773c73c19e53ba11da36f52c5037d2b6b603..723bb3c8d492da29f8e368dd0c42b352d1e49c80 100644 (file)
@@ -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