Message118973
Let me fix this function a little bit...
def isleap(year):
"""Return True for leap years, False for non-leap years."""
if year == 0:
raise ValueError('year 0 does not exist')
return (year % 4 == 0) and (year % 100 != 0) or (year % 400 == 0)
This function, however, does not mind if you give it a negative number. But I think we can leave this option to mean B.C. (Before Christ), so calendar.isleap(-240) would mean 240 B.C., which was a leap year.
About the if year == 0 check... Well, read Wikipedia's article http://en.wikipedia.org/wiki/0_(year) which clearly states that "Year zero does not exist in the widely used Gregorian calendar or in its predecessor, the Julian calendar." So we raise a ValueError if this value is used in the calendar.isleap() function.
I have uploaded a patch that fixes this function. Please apply it to the trunk and also to the maintenance brances. |
|
Date |
User |
Action |
Args |
2010-10-17 19:54:25 | Retro | set | recipients:
+ Retro, georg.brandl, terry.reedy, belopolsky, pjenvey, eric.araujo, r.david.murray, shadikka |
2010-10-17 19:54:25 | Retro | set | messageid: <1287345265.27.0.958642819907.issue10073@psf.upfronthosting.co.za> |
2010-10-17 19:54:23 | Retro | link | issue10073 messages |
2010-10-17 19:54:23 | Retro | create | |
|