[ZCM] [ZC] 279/ 2 Comment "strftime's DateTime bug in windoze"

Collector: Zope Bugs and Patches ... zope-coders@zope.org
Sat, 09 Mar 2002 09:49:11 -0500


Issue #279 Update (Comment) "strftime's DateTime bug in windoze"
 Status Pending, Zope/bug critical
To followup, visit:
  http://collector.zope.org/Zope/279

==============================================================
= Comment - Entry #2 by stevea on Mar 9, 2002 9:49 am

Python does not guarentee that the time module will function outside of the range Epoch -> 2038.

I propose this patch, although it doesn't solve the real problem of DateTime being less than useful in this case:

 --- DateTime.py.orig    Sat Mar  9 14:43:35 2002
 +++ DateTime.py Sat Mar  9 14:45:48 2002
 @@ -379,11 +379,10 @@
      '''gmtime with a safety zone.'''
      try:
          t_int = int(t)
 -    except OverflowError:
 +        return gmtime(t_int)
 +    except (OverflowError,IOError):
          raise 'TimeError', 'The time %f is beyond the range ' \
                'of this Python implementation.' % float(t)
 -    rval = gmtime(t_int)
 -    return rval
  
  def safelocaltime(t):
      '''localtime with a safety zone.'''


________________________________________
= Request - Entry #1 by Anonymous User on Mar 9, 2002 9:30 am

When I try to format a DateTime object older than 1970/1/1, using strftime(), I receive an:

Error Type: IOError
Error Value: [Errno 22] Invalid argument

Traceback (innermost last):
  File C:\zope251b1\lib\python\ZPublisher\Publish.py, line 150, in publish_module
  File C:\zope251b1\lib\python\ZPublisher\Publish.py, line 114, in publish
  File C:\zope251b1\lib\python\Zope\__init__.py, line 159, in zpublisher_exception_hook
    (Object: Zope)
  File C:\zope251b1\lib\python\ZPublisher\Publish.py, line 98, in publish
  File C:\zope251b1\lib\python\ZPublisher\mapply.py, line 88, in mapply
    (Object: teste_s_data)
  File C:\zope251b1\lib\python\ZPublisher\Publish.py, line 39, in call_object
    (Object: teste_s_data)
  File C:\zope251b1\lib\python\Shared\DC\Scripts\Bindings.py, line 252, in __call__
    (Object: teste_s_data)
  File C:\zope251b1\lib\python\Shared\DC\Scripts\Bindings.py, line 283, in _bindAndExec
    (Object: teste_s_data)
  File C:\zope251b1\lib\python\Products\PythonScripts\PythonScript.py, line 302, in _exec
    (Object: teste_s_data)
    (Info: ({'script': <PythonScript instance at 027A40F0>, 'context': <Application instance at 01A8C650>, 'container': <Application instance at 01A8C650>, 'traverse_subpath': []}, (), {}, None))
  File Script (Python), line 4, in teste_s_data
  File C:\zope251b1\lib\python\DateTime\DateTime.py, line 1374, in strftime
  File C:\zope251b1\lib\python\DateTime\DateTime.py, line 385, in safegmtime
IOError: (see above)


==============================================================