Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6143648

Browse files
committed
SF 685011: calendar module overflow handling
Restored a Py2.2 behavior to not range check the day of the month. A user application was this exploiting undocumented, accidental "feature".
1 parent 1442dc1 commit 6143648

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Lib/calendar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def calendar(year, w=0, l=0, c=_spacing):
213213
def timegm(tuple):
214214
"""Unrelated but handy function to calculate Unix timestamp from GMT."""
215215
year, month, day, hour, minute, second = tuple[:6]
216-
days = datetime.date(year, month, day).toordinal() - _EPOCH_ORD
216+
days = datetime.date(year, month, 1).toordinal() - _EPOCH_ORD + day - 1
217217
hours = days*24 + hour
218218
minutes = hours*60 + minute
219219
seconds = minutes*60 + second

0 commit comments

Comments
 (0)