[Python-bugs-list] [ python-Bugs-434143 ] calendar module broken for 1900
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 06 Jul 2001 11:40:22 -0700
Bugs item #434143, was opened at 2001-06-18 04:56
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=434143&group_id=5470
>Category: Python Library
>Group: Platform-specific
Status: Open
Resolution: None
Priority: 5
Submitted By: Alexandre Fayolle (afayolle)
Assigned to: Skip Montanaro (montanaro)
Summary: calendar module broken for 1900
Initial Comment:
Hi there, this is a 'feature' I met on both 1.5.2 and
2.1.
>>> import calendar
>>> calendar.prcal(1865)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.1/calendar.py", line 160, in
prcal
print calendar(year, w, l, c),
File "/usr/lib/python2.1/calendar.py", line 179, in
calendar
cal = monthcalendar(year, amonth)
File "/usr/lib/python2.1/calendar.py", line 85, in
monthcalendar
day1, ndays = monthrange(year, month)
File "/usr/lib/python2.1/calendar.py", line 78, in
monthrange
day1 = weekday(year, month, 1)
File "/usr/lib/python2.1/calendar.py", line 69, in
weekday
secs = mktime((year, month, day, 0, 0, 0, 0, 0, 0))
ValueError: year out of range (00-99, 1900-*)
(note that the documentation only refers to 1970 as a
possible limit, and does not mention how dates in 00-99
range are processed)
Now if I try to get the calendar for year 1900 (which
is supposed to work according to the message
hereabove), I get
>>> calendar.prcal(1900)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.1/calendar.py", line 160, in
prcal
print calendar(year, w, l, c),
File "/usr/lib/python2.1/calendar.py", line 179, in
calendar
cal = monthcalendar(year, amonth)
File "/usr/lib/python2.1/calendar.py", line 85, in
monthcalendar
day1, ndays = monthrange(year, month)
File "/usr/lib/python2.1/calendar.py", line 78, in
monthrange
day1 = weekday(year, month, 1)
File "/usr/lib/python2.1/calendar.py", line 69, in
weekday
secs = mktime((year, month, day, 0, 0, 0, 0, 0, 0))
OverflowError: mktime argument out of range
I guess this is low priority.
Cheers
Alexandre Fayolle
----------------------------------------------------------------------
>Comment By: Skip Montanaro (montanaro)
Date: 2001-07-06 11:40
Message:
Logged In: YES
user_id=44345
calendar.py is a *very* old module. Version 1.1 has a date
of
13-Oct-90. The message about the ranges almost certainly
comes from the days when Guido and his pals at CWI were
developing Python on Macs. I just tried:
time.mktime((1900,1,1,0,0,0,0,0,0))
on my iMac and it works. If the year is 1899 it generates
the
traceback. A year of 1 is currently interpreted as 2001.
I'm not sure this is worth fixing, other than to document
the
limitations better. If you want to display calendars
perhaps
you should look at Marc-Andre Lemburg's mx.DateTime
module, which supports a much wider range of dates.
Skip
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=434143&group_id=5470