Closes bpo-28281: Remove year (1-9999) limits on the weekday() function. (#4109)
Patch by Mark Gollahon.
diff --git a/Lib/calendar.py b/Lib/calendar.py
index fb594e0..3828c43 100644
--- a/Lib/calendar.py
+++ b/Lib/calendar.py
@@ -111,8 +111,9 @@
def weekday(year, month, day):
- """Return weekday (0-6 ~ Mon-Sun) for year (1970-...), month (1-12),
- day (1-31)."""
+ """Return weekday (0-6 ~ Mon-Sun) for year, month (1-12), day (1-31)."""
+ if not datetime.MINYEAR <= year <= datetime.MAXYEAR:
+ year = 2000 + year % 400
return datetime.date(year, month, day).weekday()