[Zope-Checkins] CVS: Zope/lib/python/DateTime - DateTime.py:1.79.14.1
Torped Strategy and Communications
info@torped.se
Mon, 14 Oct 2002 13:03:28 -0400
Update of /cvs-repository/Zope/lib/python/DateTime
In directory cvs.zope.org:/tmp/cvs-serv22832/lib/python/DateTime
Modified Files:
Tag: lennart-collector_411_fix-branch
DateTime.py
Log Message:
Fix for Collector issue #411. rfc822() is now rfc2822 compliant.
=== Zope/lib/python/DateTime/DateTime.py 1.79 => 1.79.14.1 ===
--- Zope/lib/python/DateTime/DateTime.py:1.79 Wed Aug 14 17:33:49 2002
+++ Zope/lib/python/DateTime/DateTime.py Mon Oct 14 13:03:27 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