Re: [Zope-dev] DateTime, strftime and TimeError
--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.00 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 pgpgJg9WCW74N.pgp Description: PGP signature ___ 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 )
Re: [Zope-dev] DateTime, strftime and TimeError
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.00 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) * 100) +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 )
Re: [Zope-dev] DateTime, strftime and TimeError
--On Donnerstag, 12. Mai 2005 18:34 Uhr +0200 Santi Camps [EMAIL PROTECTED] wrote: 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.00 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. If you provide some unittests then this would make a perfect patch :-) -aj pgpo6RG0bY2K7.pgp Description: PGP signature ___ 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 )
Re: [Zope-dev] DateTime, strftime and TimeError
En/na Andreas Jung ha escrit: --On Donnerstag, 12. Mai 2005 18:34 Uhr +0200 Santi Camps [EMAIL PROTECTED] wrote: 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.00 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. If you provide some unittests then this would make a perfect patch :-) -aj I'm trying to do it, but one test fails. I can't understand this behaviour: DateTime('2004/01/01')._tz 'GMT+1' DateTime('2000/06/16')._tz 'GMT+2' Why different time zones are assigned ? I was thinking that the machine time zone was always used when not specified Santi Camps ___ 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 )
Re: [Zope-dev] DateTime, strftime and TimeError
Andreas Jung wrote at 2005-5-12 14:24 +0200: ... 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). It would not be too difficult to reimplement strftime in Python -- especially with the information held in a DateTime. Maybe an exercise for someone who needs strftime for dates outside the supported range? -- Dieter ___ 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 )
Re: [Zope-dev] DateTime, strftime and TimeError
On May 11, 2005, at 10:08 AM, Santi Camps wrote:I think its known that using strftime method of DateTime module with dates = 1900 or = 2038, a TimeError is raised. For instance:DateTime can handle dates with larger ranges, it just can't display them with the strftime method.DateTime's strftime method is impelemented with the standard C libraries' strftime(), and a C time_t datatype only represents dates between 1970 and 2038.___ 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 )
Re: [Zope-dev] DateTime, strftime and TimeError
En/na Andrew Langmead ha escrit: On May 11, 2005, at 10:08 AM, Santi Camps wrote: I think its known that using strftime method of DateTime module with dates = 1900 or = 2038, a TimeError is raised. For instance: DateTime can handle dates with larger ranges, it just can't display them with the strftime method. DateTime's strftime method is impelemented with the standard C libraries' strftime(), and a C time_t datatype only represents dates between 1970 and 2038. Yes, I know, but displaying them through a datetime.datetime object the display can also work fine. That's my proposal. Santi Camps ___ 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 )