Issue 3336: datetime weekday() function (original) (raw)
Leap year ignored each century (2100, 2200, 2300, etc.) except 2000 for the weekday() function. This code reproduces the error:
import datetime datetime.date(2100,2,29).weekday()
Error message: ValueError: day is out of range for the month
Also, this causes the weekday to be 1 day off from March 1st, 2100 to February 28th 2200 and 2 days off...
The error message is correct. In the Gregorian calendar, years divisible by 100 are not leap years, unless they're also divisible by 400. So 2000, 2400, 2800, ..., are leap years, but 2100, 2200, 2300, 2500, 2600, 2700, 2900, ... are not leap years. Look it up (anywhere ;-)).