Annoyed - Python 2.2.1 BUG in calendar module
skip at pobox.com
Thu Oct 3 19:16:35 CEST 2002
Kaleb> PS: here is the traceback:
>>>> import calendar
Kaleb> Traceback (most recent call last):
Kaleb> File "<stdin>", line 1, in ?
Kaleb> File "c:\progra~1\python22\lib\calendar.py", line 122, in
Kaleb> day1, ndays = monthrange(year, month)
Kaleb> File "c:\progra~1\python22\lib\calendar.py", line 115, in monthrange
Kaleb> day1 = weekday(year, month, 1)
Kaleb> File "c:\progra~1\python22\lib\calendar.py", line 106, in weekday
Kaleb> secs = mktime((year, month, day, 0, 0, 0, 0, 0, 0))
Kaleb> OverflowError: mktime argument out of range
Kaleb> The error is identical under Linux
Note that mktime comes from the time module. The time module's docs say, in
There are two standard representations of time. One is the number of
seconds since the Epoch, in UTC (a.k.a. GMT). It may be an integer or a
floating point number (to represent fractions of seconds). The Epoch is
system-defined; on Unix, it is generally January 1st, 1970. The actual
value can be retrieved by calling gmtime(0).
mktime() -- convert local time tuple to seconds since Epoch
Two suggestions before heading off to do your own thing:
1. Fred Drake was working on a more capable date-time representation
during the summer. The code is in the SF sandbox:
You might also want to read his DateTimeWiki:
before implementing something different.
2. Perhaps someone has created some calendar stuff based upon Marc-André
Lemburg's mx.DateTime package (look here: <http://www.egenix.com/>).
That is a very well wrung-out package and has a lot more
functionality than Fred's stuff.
Skip Montanaro - skip at pobox.com
"Airplanes don't fly until the paperwork equals the weight of the
aircraft. Same with i18N." - from the "Perl, Unicode and i18N FAQ"
More information about the Python-list