summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-10-09 12:42:04 (GMT)
committerGuido van Rossum <guido@python.org>2000-10-09 12:42:04 (GMT)
commit46735add5fd292d1c0141aefa23f92814b15cac3 (patch)
tree370b0bf69b77ae90c1c6a50e315068260dbeae38
parente9f922f4977aaffb21ac68249457044178ba8e02 (diff)
downloadcpython-46735add5fd292d1c0141aefa23f92814b15cac3.zip
cpython-46735add5fd292d1c0141aefa23f92814b15cac3.tar.gz
cpython-46735add5fd292d1c0141aefa23f92814b15cac3.tar.bz2
Fixed leapdays(). From Patch #101841, by Denis S. Otkidach.
-rw-r--r--Lib/calendar.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/calendar.py b/Lib/calendar.py
index 8ac71f1..41bb191 100644
--- a/Lib/calendar.py
+++ b/Lib/calendar.py
@@ -54,8 +54,10 @@ def isleap(year):
def leapdays(y1, y2):
"""Return number of leap years in range [y1, y2).
- Assume y1 <= y2 and no funny (non-leap century) years."""
- return (y2+3)/4 - (y1+3)/4
+ Assume y1 <= y2."""
+ y1 -= 1
+ y2 -= 1
+ return (y2/4 - y1/4) - (y2/100 - y1/100) + (y2/400 - y1/400)
def weekday(year, month, day):
"""Return weekday (0-6 ~ Mon-Sun) for year (1970-...), month (1-12),