En/na Andreas Jung ha escrit:



--On Mittwoch, 11. Mai 2005 16:08 Uhr +0200 Santi Camps <[EMAIL PROTECTED]> wrote:


>> d = DateTime('2045/30/01') >> d.strftime('%d/%m/%Y') DateTime.DateTime.TimeError: The time 2369343600.000000 is beyond the range of this Python implementation

I've read that the reason was a validation to avoid int overflows.   I
think this could be fixed using datetime module (new in python 2.3)
instead of old time.localtime


After some testing: datetime has the same problems and it is unlikely that we can solve
this problem in Zope as long as the underlying implementation in the libc sux (or better is
constrained on 32 bit systems).


-aj

At least is possible to fix the problem in strftime method. I attach a patch that works for me. Hope this can be commited.


Santi Camps


Index: lib/python/DateTime/DateTime.py
===================================================================
--- lib/python/DateTime/DateTime.py	(revision 30324)
+++ lib/python/DateTime/DateTime.py	(working copy)
@@ -18,6 +18,7 @@
 import re, math,  DateTimeZone
 from time import time, gmtime, localtime
 from time import daylight, timezone, altzone, strftime
+from datetime import datetime
 
 default_datefmt = None
 
@@ -1481,7 +1482,12 @@
 
     def strftime(self, format):
         # Format the date/time using the *current timezone representation*.
-        return strftime(format, safelocaltime(self.timeTime()))
+        lt = safelocaltime(time())
+        ltz = self.localZone(lt)
+        zself = self - _tzoffset(self._tz, ltz)/86400.0
+        microseconds = int((zself._second - zself._nearsec) * 1000000)
+        return datetime(zself._year, zself._month, zself._day, zself._hour,  
+               zself._minute, int(zself._nearsec), microseconds).strftime(format) 
 
     # General formats from previous DateTime
     def Date(self):
_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to