[Zope-Checkins] CVS: Zope/lib/python/DateTime - DateTime.py:1.85.12.7

Yvo Schubbe schubbe at web.de
Thu Jan 1 13:02:28 EST 2004


Update of /cvs-repository/Zope/lib/python/DateTime
In directory cvs.zope.org:/tmp/cvs-serv13410/lib/python/DateTime

Modified Files:
      Tag: Zope-2_7-branch
	DateTime.py 
Log Message:
- fixed _calcTimezoneName (Collector #484)
- fixed safegmtime to catch ValueError instead of IOError (Python 2.3)
- synced safelocaltime with safegmtime
- some whitspace cleanup


=== Zope/lib/python/DateTime/DateTime.py 1.85.12.6 => 1.85.12.7 ===
--- Zope/lib/python/DateTime/DateTime.py:1.85.12.6	Thu Nov 20 12:12:19 2003
+++ Zope/lib/python/DateTime/DateTime.py	Thu Jan  1 13:01:57 2004
@@ -409,8 +409,8 @@
         t_int = int(t)
         if isinstance(t_int, long):
             raise OverflowError # Python 2.3 fix: int can return a long!
-        return  gmtime(t_int)
-    except (IOError, OverflowError):
+        return gmtime(t_int)
+    except (ValueError, OverflowError):
         raise TimeError, 'The time %f is beyond the range ' \
               'of this Python implementation.' % float(t)
 
@@ -420,11 +420,10 @@
         t_int = int(t)
         if isinstance(t_int, long):
             raise OverflowError # Python 2.3 fix: int can return a long!
-    except OverflowError:
+        return localtime(t_int)
+    except (ValueError, OverflowError):
         raise TimeError, 'The time %f is beyond the range ' \
               'of this Python implementation.' % float(t)
-    rval = localtime(t_int)
-    return rval
 
 def _tzoffset2rfc822zone(seconds):
     """Takes an offset, such as from _tzoffset(), and returns an rfc822 
@@ -891,6 +890,11 @@
             yr = ((yr - 1970) % 28) + 1970
             x = _calcDependentSecond2(yr,mo,dy,hr,mn,sc)
             nearTime = x - fsetAtEpoch - long(EPOCH) + 86400L + ms
+
+            # nearTime might still be negative if we are east of Greenwich.
+            # But we can asume on 1969/12/31 were no timezone changes.
+            nearTime = max(0, nearTime)
+
             ltm = safelocaltime(nearTime)
         tz = self.localZone(ltm)
         return tz
@@ -1028,7 +1032,7 @@
                     else:
                         day=ints[0]
                         month=ints[1]
-    
+
             elif ints[0] <= 12:
                 month=ints[0]
                 day=ints[1]
@@ -1489,7 +1493,7 @@
     def rfc822(self):
         """Return the date in RFC 822 format"""
         tzoffset = _tzoffset2rfc822zone(_tzoffset(self._tz, self._t))
-            
+
         return '%s, %2.2d %s %d %2.2d:%2.2d:%2.2d %s' % (
             self._aday,self._day,self._amon,self._year,
             self._hour,self._minute,self._nearsec,tzoffset)
@@ -1656,7 +1660,6 @@
             raise SyntaxError, (
                 'Not an ISO 8601 compliant date string: "%s"' % s)
 
-
     def __parse_iso8601(self,s):
         """ parse an ISO 8601 compliant date """
         year=0
@@ -1687,8 +1690,8 @@
             if fields[5]:   seconds  = int(fields[5])
             if fields[6]:   seconds  = seconds+float(fields[6])
             z = fields[7]
-            
-	    if z and z.startswith('Z'):
+
+            if z and z.startswith('Z'):
                 # Waaaa! This is wrong, since 'Z' and '+HH:MM'
                 # are supposed to be mutually exclusive.
                 # It's only here to prevent breaking 2.7 beta.




More information about the Zope-Checkins mailing list