Commit 52b1e50c authored by 's avatar

Merged fix to rfc1123_date formatting

parent 4ed67d05
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
"""Commonly used utility functions.""" """Commonly used utility functions."""
__version__='$Revision: 1.7 $'[11:-2] __version__='$Revision: 1.8 $'[11:-2]
import sys, os, time import sys, os, time
from string import rfind from string import rfind
...@@ -101,16 +101,17 @@ monthname = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', ...@@ -101,16 +101,17 @@ monthname = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
def iso8601_date(ts=None, format='%Y-%m-%dT%H:%M:%SZ'): def iso8601_date(ts=None):
# Return an ISO 8601 formatted date string, required # Return an ISO 8601 formatted date string, required
# for certain DAV properties. # for certain DAV properties.
# '2000-11-10T16:21:09-08:00 # '2000-11-10T16:21:09-08:00
if ts is None: ts=time.time() if ts is None: ts=time.time()
return time.strftime(format, time.gmtime(ts)) return time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(ts))
def rfc850_date(ts=None, format='%A, %d-%b-%y %H:%M:%S GMT'): def rfc850_date(ts=None):
# Return an HTTP-date formatted date string. # Return an HTTP-date formatted date string.
# 'Friday, 10-Nov-00 16:21:09 GMT' # 'Friday, 10-Nov-00 16:21:09 GMT'
if ts is None: ts=time.time()
year, month, day, hh, mm, ss, wd, y, z = time.gmtime(ts) year, month, day, hh, mm, ss, wd, y, z = time.gmtime(ts)
return "%s, %02d-%3s-%2s %02d:%02d:%02d GMT" % ( return "%s, %02d-%3s-%2s %02d:%02d:%02d GMT" % (
weekday_full[wd], weekday_full[wd],
...@@ -118,15 +119,13 @@ def rfc850_date(ts=None, format='%A, %d-%b-%y %H:%M:%S GMT'): ...@@ -118,15 +119,13 @@ def rfc850_date(ts=None, format='%A, %d-%b-%y %H:%M:%S GMT'):
str(year)[2:], str(year)[2:],
hh, mm, ss) hh, mm, ss)
def rfc1123_date(ts=None, format='%a, %d %b %Y %H:%M:%S GMT'): def rfc1123_date(ts=None):
# Return an RFC 1123 format date string, required for # Return an RFC 1123 format date string, required for
# use in HTTP Date headers per the HTTP 1.1 spec. # use in HTTP Date headers per the HTTP 1.1 spec.
# 'Fri, 10 Nov 2000 16:21:09 GMT' # 'Fri, 10 Nov 2000 16:21:09 GMT'
# XXX It looks like the 'format' argument is not just unused, but
# useless. klm 11/13/2000.
if ts is None: ts=time.time() if ts is None: ts=time.time()
year, month, day, hh, mm, ss, wd, y, z = time.gmtime(ts) year, month, day, hh, mm, ss, wd, y, z = time.gmtime(ts)
return "%s, %02d-%3s-%4d %02d:%02d:%02d GMT" % (weekday_abbr[wd], return "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (weekday_abbr[wd],
day, monthname[month], day, monthname[month],
year, year,
hh, mm, ss) hh, mm, ss)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment