calendar module in 2.3

Richard Jones rjones at ekit-inc.com
Wed Feb 5 23:17:21 EST 2003


The calendar module has lost a significant area of functionality in Python 2.3 
- that of handling overflows in the tuples passed to timegm().

Python 2.2.2 (#1, Oct 28 2002, 16:39:08)
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import time,calendar
>>> time.gmtime(calendar.timegm((2003,1,30,0,0,0,0,0,0)))
(2003, 1, 30, 0, 0, 0, 3, 30, 0)
>>> time.gmtime(calendar.timegm((2003,2,30,0,0,0,0,0,0)))
(2003, 3, 2, 0, 0, 0, 6, 61, 0)
>>>

Python 2.3a1 (#1, Feb  6 2003, 14:54:16)
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import time,calendar
>>> time.gmtime(calendar.timegm((2003,1,30,0,0,0,0,0,0)))
(2003, 1, 30, 0, 0, 0, 3, 30, 0)
>>> time.gmtime(calendar.timegm((2003,2,30,0,0,0,0,0,0)))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.3/calendar.py", line 216, in timegm
    days = datetime.date(year, month, day).toordinal() - _EPOCH_ORD
ValueError: day is out of range for month
>>>


Is this functionality likely to be reinstated for 2.3's release?


    Richard






More information about the Python-list mailing list