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

Torped Strategy and Communications info@torped.se
Tue, 15 Oct 2002 13:53:38 -0400


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

Modified Files:
	DateTime.py 
Log Message:
Fix for collector issue #411. DateTime.rfc822() is not rfc2822 compliant.

=== Zope/lib/python/DateTime/DateTime.py 1.79 => 1.80 ===
--- Zope/lib/python/DateTime/DateTime.py:1.79	Wed Aug 14 17:33:49 2002
+++ Zope/lib/python/DateTime/DateTime.py	Tue Oct 15 13:53:37 2002
@@ -17,8 +17,7 @@
 
 import re,sys, os, math,  DateTimeZone
 from time import time, gmtime, localtime, asctime
-from time import timezone, strftime
-from time import daylight, timezone, altzone
+from time import daylight, timezone, altzone, strftime
 from types import InstanceType,IntType,FloatType,StringType,UnicodeType
 try: from time import tzname
 except: tzname=('UNKNOWN','UNKNOWN')
@@ -400,6 +399,9 @@
     rval = localtime(t_int)
     return rval
 
+def _tzoffset2rfc822zone(seconds):
+    return "%+03d%02d" % divmod( (-seconds/60), 60) 
+
 
 class DateTime:
     """DateTime objects represent instants in time and provide
@@ -1435,9 +1437,16 @@
 
     def rfc822(self):
         """Return the date in RFC 822 format"""
+        if self._tz == self._localzone0: #Use local standard time
+            tzoffset = _tzoffset2rfc822zone(localzone)
+        elif self._tz == self._localzone1: # Use local daylight saving time
+            tzoffset = _tzoffset2rfc822zone(altzone)
+        else:
+            tzoffset = '-0000' # unknown time zone offset
+            
         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,self._tz)
+            self._hour,self._minute,self._nearsec,tzoffset)
 
 
     # New formats