Update of /cvsroot/mailman/mailman/Mailman
In directory usw-pr-cvs1:/tmp/cvs-serv1410
Modified Files:
Tag: Release_2_0_1-branch
Utils.py
Log Message:
formatdate(): Steal this implementation from the email package (it's
Python 1.5.2 compatible ;), to support the mandatory RFC 2822 Date:
field.
Index: Utils.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Utils.py,v
retrieving revision 1.104.2.4
retrieving revision 1.104.2.5
diff -C2 -d -r1.104.2.4 -r1.104.2.5
*** Utils.py 25 Jul 2001 18:06:46 -0000 1.104.2.4
--- Utils.py 3 Apr 2002 22:47:12 -0000 1.104.2.5
***************
*** 28,31 ****
--- 28,32 ----
import string
import re
+ import time
from UserDict import UserDict
from types import StringType
***************
*** 691,692 ****
--- 692,739 ----
raise TypeError('unexpected keywords')
file.write(string.join(map(str, args), sep) + end)
+
+
+
+ def formatdate(timeval=None, localtime=0):
+ """Returns a date string as specified by RFC 2822, e.g.:
+
+ Fri, 09 Nov 2001 01:08:47 -0000
+
+ Optional timeval if given is a floating point time value as accepted by
+ gmtime() and localtime(), otherwise the current time is used.
+
+ Optional localtime is a flag that when true, interprets timeval, and
+ returns a date relative to the local timezone instead of UTC, properly
+ taking daylight savings time into account.
+ """
+ # Note: we cannot use strftime() because that honors the locale and RFC
+ # 2822 requires that day and month names be the English abbreviations.
+ if timeval is None:
+ timeval = time.time()
+ if localtime:
+ now = time.localtime(timeval)
+ # Calculate timezone offset, based on whether the local zone has
+ # daylight savings time, and whether DST is in effect.
+ if time.daylight and now[-1]:
+ offset = time.altzone
+ else:
+ offset = time.timezone
+ hours, minutes = divmod(abs(offset), 3600)
+ # Remember offset is in seconds west of UTC, but the timezone is in
+ # minutes east of UTC, so the signs differ.
+ if offset > 0:
+ sign = '-'
+ else:
+ sign = '+'
+ zone = '%s%02d%02d' % (sign, hours, minutes / 60)
+ else:
+ now = time.gmtime(timeval)
+ # Timezone offset is always -0000
+ zone = '-0000'
+ return '%s, %02d %s %04d %02d:%02d:%02d %s' % (
+ ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'][now[6]],
+ now[2],
+ ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][now[1] - 1],
+ now[0], now[3], now[4], now[5],
+ zone)
_______________________________________________
Mailman-checkins mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/mailman-checkins