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

Chris McDonough chrism@zope.com
Sun, 24 Nov 2002 18:35:26 -0500


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

Modified Files:
      Tag: chrism-install-branch
	DateTime.py 
Log Message:
Merge with HEAD.


=== Zope/lib/python/DateTime/DateTime.py 1.79.4.1 => 1.79.4.2 ===
--- Zope/lib/python/DateTime/DateTime.py:1.79.4.1	Sat Oct 26 15:51:38 2002
+++ Zope/lib/python/DateTime/DateTime.py	Sun Nov 24 18:35:25 2002
@@ -362,6 +362,10 @@
     return int(yr),int(mo),int(dy)
 
 def _tzoffset(tz, t):
+    """Returns the offset in seconds to GMT from a specific timezone (tz) at 
+    a specific time (t).  NB! The _tzoffset result is the same same sign as 
+    the time zone, i.e. GMT+2 has a 7200 second offset. This is the opposite 
+    sign of time.timezone which (confusingly) is -7200 for GMT+2."""
     try:
         return DateTime._tzinfo[tz].info(t)[0]
     except:
@@ -400,7 +404,10 @@
     return rval
 
 def _tzoffset2rfc822zone(seconds):
-    return "%+03d%02d" % divmod( (-seconds/60), 60) 
+    """Takes an offset, such as from _tzoffset(), and returns an rfc822 
+       compliant zone specification. Please note that the result of 
+       _tzoffset() is the negative of what time.localzone and time.altzone is."""
+    return "%+03d%02d" % divmod( (seconds/60), 60) 
 
 
 class DateTime:
@@ -1437,17 +1444,11 @@
 
     def rfc822(self):
         """Return the date in RFC 822 format"""
-        if self._tz == self._localzone0: #Use local standard time
-            tzoffset = _tzoffset2rfc822zone(timezone)
-        elif self._tz == self._localzone1: # Use local daylight saving time
-            tzoffset = _tzoffset2rfc822zone(altzone)
-        else:
-            tzoffset = '-0000' # unknown time zone offset
+        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)
-
 
     # New formats
     def fCommon(self):