TimeError when using fmt="%Y-%m-%d"
Hi all This snippet generates a TimeError (I've appended the traceback below):: <input name="FirstContactDate" value="<dtml-var FirstContactDate fmt="%Y-%m-%d">" size="10"> This, however, works fine:: <input name="FirstContactDate" value="<dtml-var FirstContactDate fmt="year" >-<dtml-var FirstContactDate fmt="month" >-<dtml-var FirstContactDate fmt="day">" size="10"> The fmt="%Y-%m-%d" idiom works fine elsewhere in my code. Any idea what might be wrong with the first snippet above? Regards, Jean Jordaan Zope Error Zope has encountered an error while publishing this resource. Error Type: TimeError Error Value: The time -2208988800.000000 is beyond the range of this Python implementation. [...] Traceback (innermost last): File /usr/local/zope/2-3-0/lib/python/ZPublisher/Publish.py, line 223, in publish_module File /usr/local/zope/2-3-0/lib/python/ZPublisher/Publish.py, line 187, in publish File /usr/local/zope/2-3-0/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: 1177) File /usr/local/zope/2-3-0/lib/python/ZPublisher/Publish.py, line 171, in publish File /usr/local/zope/2-3-0/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: editProfileForm) File /usr/local/zope/2-3-0/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: editProfileForm) File /usr/local/zope/2-3-0/lib/python/OFS/DTMLMethod.py, line 189, in __call__ (Object: editProfileForm) File /usr/local/zope/2-3-0/lib/python/DocumentTemplate/DT_String.py, line 540, in __call__ (Object: editProfileForm) File /usr/local/zope/2-3-0/lib/python/DocumentTemplate/DT_With.py, line 151, in render (Object: Contacts.Profiles.getItem(new_profile_id)) File /usr/local/zope/2-3-0/lib/python/OFS/DTMLMethod.py, line 182, in __call__ (Object: viewOrEditProfile) File /usr/local/zope/2-3-0/lib/python/DocumentTemplate/DT_String.py, line 540, in __call__ (Object: viewOrEditProfile) File /usr/local/zope/2-3-0/lib/python/OFS/DTMLMethod.py, line 182, in __call__ (Object: editInstanceForm) File /usr/local/zope/2-3-0/lib/python/DocumentTemplate/DT_String.py, line 540, in __call__ (Object: editInstanceForm) File /usr/local/zope/2-3-0/lib/python/DocumentTemplate/DT_In.py, line 719, in renderwob (Object: ProfileCategories.getAllProfileCategories(ProfileCategories)) File /usr/local/zope/2-3-0/lib/python/DocumentTemplate/DT_Var.py, line 308, in render (Object: FirstContactDate) (Info: ('FirstContactDate', DateTime('1900/01/01'), {'fmt': '%Y-%m-%d', '': 'FirstContactDate'})) File /usr/local/zope/2-3-0/lib/python/DateTime/DateTime.py, line 1621, in __call__ File /usr/local/zope/2-3-0/lib/python/DateTime/DateTime.py, line 1395, in strftime File /usr/local/zope/2-3-0/lib/python/DateTime/DateTime.py, line 459, in safegmtime TimeError: (see above)
What is the value of FirstContactDate ? Andreas ----- Original Message ----- From: "Jean Jordaan" <jean@upfrontsystems.co.za> To: <zope@zope.org> Sent: Monday, October 29, 2001 10:29 Subject: [Zope] TimeError when using fmt="%Y-%m-%d"
Hi all
This snippet generates a TimeError (I've appended the traceback below)::
<input name="FirstContactDate" value="<dtml-var FirstContactDate fmt="%Y-%m-%d">" size="10">
This, however, works fine::
<input name="FirstContactDate" value="<dtml-var FirstContactDate fmt="year" >-<dtml-var FirstContactDate fmt="month" >-<dtml-var FirstContactDate fmt="day">" size="10">
The fmt="%Y-%m-%d" idiom works fine elsewhere in my code. Any idea what might be wrong with the first snippet above?
Regards, Jean Jordaan
Zope Error Zope has encountered an error while publishing this resource. Error Type: TimeError Error Value: The time -2208988800.000000 is beyond the range of this Python implementation. [...]
Traceback (innermost last): File /usr/local/zope/2-3-0/lib/python/ZPublisher/Publish.py, line 223, in publish_module File /usr/local/zope/2-3-0/lib/python/ZPublisher/Publish.py, line 187, in publish File /usr/local/zope/2-3-0/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: 1177) File /usr/local/zope/2-3-0/lib/python/ZPublisher/Publish.py, line 171, in publish File /usr/local/zope/2-3-0/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: editProfileForm) File /usr/local/zope/2-3-0/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: editProfileForm) File /usr/local/zope/2-3-0/lib/python/OFS/DTMLMethod.py, line 189, in __call__ (Object: editProfileForm) File /usr/local/zope/2-3-0/lib/python/DocumentTemplate/DT_String.py, line 540, in __call__ (Object: editProfileForm) File /usr/local/zope/2-3-0/lib/python/DocumentTemplate/DT_With.py, line 151, in render (Object: Contacts.Profiles.getItem(new_profile_id)) File /usr/local/zope/2-3-0/lib/python/OFS/DTMLMethod.py, line 182, in __call__ (Object: viewOrEditProfile) File /usr/local/zope/2-3-0/lib/python/DocumentTemplate/DT_String.py, line 540, in __call__ (Object: viewOrEditProfile) File /usr/local/zope/2-3-0/lib/python/OFS/DTMLMethod.py, line 182, in __call__ (Object: editInstanceForm) File /usr/local/zope/2-3-0/lib/python/DocumentTemplate/DT_String.py, line 540, in __call__ (Object: editInstanceForm) File /usr/local/zope/2-3-0/lib/python/DocumentTemplate/DT_In.py, line 719, in renderwob (Object: ProfileCategories.getAllProfileCategories(ProfileCategories)) File /usr/local/zope/2-3-0/lib/python/DocumentTemplate/DT_Var.py, line 308, in render (Object: FirstContactDate) (Info: ('FirstContactDate', DateTime('1900/01/01'), {'fmt': '%Y-%m-%d', '': 'FirstContactDate'})) File /usr/local/zope/2-3-0/lib/python/DateTime/DateTime.py, line 1621, in __call__ File /usr/local/zope/2-3-0/lib/python/DateTime/DateTime.py, line 1395, in strftime File /usr/local/zope/2-3-0/lib/python/DateTime/DateTime.py, line 459, in safegmtime TimeError: (see above)
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Hi Andreas
What is the value of FirstContactDate ?
Here it is:
Traceback (innermost last): [...] (Object: FirstContactDate) (Info: ('FirstContactDate', DateTime('1900/01/01'), {'fmt': '%Y-%m-%d', '': 'FirstContactDate'})) [...]
The object being rendered is a ZClass. FirstContactDate is a property of type 'date', and its default value is 1900/01/01. Regards, Jean
This is the same problem as described earlier. The representation of the date as integer is out the range for integers. Andreas ----- Original Message ----- From: "Jean Jordaan" <jean@upfrontsystems.co.za> To: "Andreas Jung" <andreas@zope.com>; <zope@zope.org> Sent: Monday, October 29, 2001 10:50 Subject: RE: [Zope] TimeError when using fmt="%Y-%m-%d"
Hi Andreas
What is the value of FirstContactDate ?
Here it is:
Traceback (innermost last): [...] (Object: FirstContactDate) (Info: ('FirstContactDate', DateTime('1900/01/01'), {'fmt': '%Y-%m-%d', '': 'FirstContactDate'})) [...]
The object being rendered is a ZClass. FirstContactDate is a property of type 'date', and its default value is 1900/01/01.
Regards, Jean
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
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'
participants (2)
-
Andreas Jung -
Jean Jordaan