[Zope] TimeError when using fmt="%Y-%m-%d"

Jean Jordaan jean@upfrontsystems.co.za
Tue, 30 Oct 2001 11:10:11 +0200


Hi Andreas

> This is the same problem as described earlier. The representation
> of the date as integer is out the range for integers.

This baffled me for a bit, but I see it's easy enough to reproduce
in Python: see [1].

So in certain cases, Zope's date handling, at least on 32-bit Intel
architectures, is restricted to dates between 1901/12/13 22:15:53
GMT+2 and 2038/01/19 05:14:07 GMT+2 (see [2]).

However, this restriction only crops up when DateTime's
'safegmtime' and 'safelocaltime' come into play. This does not happen
when any of the builtin formats are used; see for instance [3].

What I want, is a short form of the ISO8601 spec, namely '1900-01-01'
with no time info. There is no standard form for this, and 'strftime'
calls 'safegmtime', which raises an OverflowError.

So it seems there are three routes for me to get what I want:

  1. get the time in ISO format and display only the first 10
     characters;

  2. display the year, a dash, the month, a dash, and the day, one
     after the other. I guess 1. would be nicer.

  3. avoid out-of-range dates.

One question: why is it safe for the builtin formats not to use
'safegmtime'?

Thanks for the pointer ..

Regards,
Jean

.. [1] -----------------------------------------------------------
$ pwd
/usr/local/zope/2-3-0/lib/python
$ python
Python 1.5.2 (#1, Jul 12 2000, 10:39:14)  [GCC 2.96 20000702 (experimental)]
on linux-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import DateTime
>>> nineteenhundred = DateTime.DateTime('1900/01/01')
>>> print nineteenhundred
1900/01/01
>>> nineteenhundred.timeTime()
-2208996000.0
>>> DateTime.DateTime(-2208996000.0)
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "/usr/local/zope/2-3-0/lib/python/DateTime/DateTime.py", line 730, in
__init__
    lt = safelocaltime(t)
  File "/usr/local/zope/2-3-0/lib/python/DateTime/DateTime.py", line 469, in
safelocaltime
    raise 'TimeError', 'The time %f is beyond the range ' \
TimeError: The time -2208996000.000000 is beyond the range of this Python
implementation.

.. [2] -----------------------------------------------------------
>>> DateTime.DateTime(-2147483647)
DateTime('1901/12/13 22:15:53 GMT+2')
>>> DateTime.DateTime(2147483647)
DateTime('2038/01/19 05:14:07 GMT+2')

.. [3] -----------------------------------------------------------
>>> nineteenhundred.ISO()
'1900-01-01 00:00:00'
>>> nineteenhundred.Day()
'Monday'