(original) (raw)

? Lib/test/db_home Index: Lib/urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.164 diff -u -r1.164 urllib.py --- Lib/urllib.py 18 Jul 2004 06:14:41 -0000 1.164 +++ Lib/urllib.py 9 Aug 2004 09:26:55 -0000 @@ -410,7 +410,7 @@ def open_local_file(self, url): """Use local file.""" - import mimetypes, mimetools, rfc822, StringIO + import mimetypes, mimetools, email.Utils, StringIO host, file = splithost(url) localname = url2pathname(file) try: @@ -418,7 +418,7 @@ except OSError, e: raise IOError(e.errno, e.strerror, e.filename) size = stats.st_size - modified = rfc822.formatdate(stats.st_mtime) + modified = email.Utils.formatdate(stats.st_mtime, asciigmt=True) mtype = mimetypes.guess_type(url)[0] headers = mimetools.Message(StringIO.StringIO( 'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' % Index: Lib/urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.75 diff -u -r1.75 urllib2.py --- Lib/urllib2.py 8 Aug 2004 01:05:14 -0000 1.75 +++ Lib/urllib2.py 9 Aug 2004 09:26:59 -0000 @@ -99,7 +99,6 @@ import posixpath import random import re -import rfc822 import sha import socket import sys @@ -1129,12 +1128,13 @@ # not entirely sure what the rules are here def open_local_file(self, req): + import email.Utils host = req.get_host() file = req.get_selector() localfile = url2pathname(file) stats = os.stat(localfile) size = stats.st_size - modified = rfc822.formatdate(stats.st_mtime) + modified = email.Utils.formatdate(stats.st_mtime, asciigmt=True) mtype = mimetypes.guess_type(file)[0] headers = mimetools.Message(StringIO( 'Content-type: %s\nContent-length: %d\nLast-modified: %s\n' % Index: Lib/email/Utils.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Utils.py,v retrieving revision 1.26 diff -u -r1.26 Utils.py --- Lib/email/Utils.py 9 May 2004 03:50:04 -0000 1.26 +++ Lib/email/Utils.py 9 Aug 2004 09:27:01 -0000 @@ -148,7 +148,7 @@ -def formatdate(timeval=None, localtime=False): +def formatdate(timeval=None, localtime=False, asciigmt=False): """Returns a date string as specified by RFC 2822, e.g.: Fri, 09 Nov 2001 01:08:47 -0000 @@ -159,6 +159,10 @@ 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. + + Optional argument asciigmt means that the timezone is written out as + an ascii string, not numeric one (so "GMT" instead of "+0000"). This + is needed for HTTP, and is only used when localtime==False. """ # Note: we cannot use strftime() because that honors the locale and RFC # 2822 requires that day and month names be the English abbreviations. @@ -183,7 +187,10 @@ else: now = time.gmtime(timeval) # Timezone offset is always -0000 - zone = '-0000' + if asciigmt: + zone = 'GMT' + else: + zone = '-0000' return '%s, %02d %s %04d %02d:%02d:%02d %s' % ( ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'][now[6]], now[2], Index: Doc/lib/emailutil.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/emailutil.tex,v retrieving revision 1.8 diff -u -r1.8 emailutil.tex --- Doc/lib/emailutil.tex 1 Oct 2002 04:33:16 -0000 1.8 +++ Doc/lib/emailutil.tex 9 Aug 2004 09:27:07 -0000 @@ -84,7 +84,7 @@ common use. \end{funcdesc} -\begin{funcdesc}{formatdate}{\optional{timeval\optional{, localtime}}} +\begin{funcdesc}{formatdate}{\optional{timeval\optional{, localtime}\optional{, asciigmt}}} Returns a date string as per \rfc{2822}, e.g.: \begin{verbatim} @@ -99,6 +99,11 @@ \var{timeval}, and returns a date relative to the local timezone instead of UTC, properly taking daylight savings time into account. The default is \code{False} meaning UTC is used. + +Optional \var{asciigmt} is a flag that when \code{True}, outputs a +date string with the timezone as an ascii string \code{GMT}, rather +than a numeric \code{-0000}. This is needed in some protocols (such +as HTTP). \end{funcdesc} \begin{funcdesc}{make_msgid}{\optional{idstring}}