Boštjan Mejak <[email protected]> added the comment:
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.
----------
keywords: +patch
Added file: http://bugs.python.org/file19255/calendar-isleap.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue10073>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com