diff options
author | Guido van Rossum <guido@python.org> | 1999-04-19 18:04:38 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1999-04-19 18:04:38 +0000 |
commit | 247a78a10dc3486f20743a154246da15d862cd5d (patch) | |
tree | 3f40a43117b53e57cedee2503e9054959f6cf99f /Lib | |
parent | f340114d7222ae22fab94122f4b77972b968a659 (diff) | |
download | cpython-git-247a78a10dc3486f20743a154246da15d862cd5d.tar.gz |
Utility function that yields a properly formatted time string.
(Idea by Jeff Bauer, code by Jeremy, renamed and "Date:" constant
stripped from return value by GvR.)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/rfc822.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/rfc822.py b/Lib/rfc822.py index 86727d0b23..292b3c96ee 100644 --- a/Lib/rfc822.py +++ b/Lib/rfc822.py @@ -873,6 +873,16 @@ def mktime_tz(data): t = time.mktime(data[:8] + (0,)) return t - data[9] - time.timezone +def formatdate(timeval=None): + """Returns time format preferred for Internet standards. + + Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 + """ + if timeval is None: + timeval = time.time() + return "%s" % time.strftime('%a, %d %b %Y %H:%M:%S GMT', + time.gmtime(timeval)) + # When used as script, run a small test program. # The first command line argument must be a filename containing one |