Message277257
This is not just not elegant, but it doesn't work if firstweekday is not 0.
The lowest level in the calendar module is itermonthdates(). But the problem is that dates outside supported range can't be represented.
While the output for December of the year 9999 looks badly formatted, calendar doesn't work at all with January of the year 1 if firstweekday is not 0:
>>> import calendar
>>> calendar.setfirstweekday(6)
>>> calendar.prmonth(1, 1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/serhiy/py/cpython-3.6/Lib/calendar.py", line 318, in prmonth
print(self.formatmonth(theyear, themonth, w, l), end=' ')
File "/home/serhiy/py/cpython-3.6/Lib/calendar.py", line 331, in formatmonth
for week in self.monthdays2calendar(theyear, themonth):
File "/home/serhiy/py/cpython-3.6/Lib/calendar.py", line 211, in monthdays2calendar
days = list(self.itermonthdays2(year, month))
File "/home/serhiy/py/cpython-3.6/Lib/calendar.py", line 179, in itermonthdays2
for date in self.itermonthdates(year, month):
File "/home/serhiy/py/cpython-3.6/Lib/calendar.py", line 162, in itermonthdates
date -= datetime.timedelta(days=days)
OverflowError: date value out of range |
|
Date |
User |
Action |
Args |
2016-09-23 08:51:31 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, rhettinger, xiang.zhang, jiangping.li |
2016-09-23 08:51:31 | serhiy.storchaka | set | messageid: <1474620691.22.0.569692204787.issue28253@psf.upfronthosting.co.za> |
2016-09-23 08:51:31 | serhiy.storchaka | link | issue28253 messages |
2016-09-23 08:51:30 | serhiy.storchaka | create | |
|