Alexander Belopolsky added the comment: > What's the use case for this?
Why did George Mallory climb Mount Everest? "Because it's there." We have two open issues complaining about calendar behavior for years 1 and 9999: #28253 and #26650. There is also a closed issue #15421 that attempted to fix an overflow in the year 9999 only to introduce a silent error. I don't think there are use cases beyond educational (demonstrating calendar periodicity?) or testing, but since several users bothered to report edge case bugs, it is probably easier to remove the limits than to properly document them. Fortunately, extending calendar to arbitrary years does not require climbing Mount Everest. Since the proleptic calendar repeats every 400 years, all we need (assuming issue 28253 patch is applied) is to fix the weekday() function as follows: def weekday(year, month, day): """Return weekday (0-6 ~ Mon-Sun) for year (1970-...), month (1-12), day (1-31).""" + if not 0 < year < 10000: + year = 2000 + year % 400 return datetime.date(year, month, day).weekday() $ ./python.exe -mcalendar 40000 12 December 40000 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 $ ./python.exe -mcalendar -104 2 February -104 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 We can also treat negative years "properly" so that year 1 is preceded by year -1, but I don't think there is any value in this. ---------- dependencies: +calendar.prcal(9999) output has a problem keywords: +easy nosy: +xiang.zhang _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28281> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com