Commit 54e2f310 authored by 's avatar

Merge date func rearrangement from 2.2 branch

parent 6e6e3eef
"""HTTP 1.1 / WebDAV client library.""" """HTTP 1.1 / WebDAV client library."""
__version__='$Revision: 1.11 $'[11:-2] __version__='$Revision: 1.12 $'[11:-2]
import sys, os, string, regex, time, types import sys, os, string, regex, time, types
import socket, httplib, mimetools import socket, httplib, mimetools
from types import FileType from types import FileType
from mimetypes import guess_type from mimetypes import guess_type
from base64 import encodestring from base64 import encodestring
from common import rfc1123_date
from cStringIO import StringIO from cStringIO import StringIO
from whrandom import random from whrandom import random
from urllib import quote from urllib import quote
...@@ -423,14 +424,6 @@ find_xml="""<?xml version="1.0" encoding="utf-8" ?> ...@@ -423,14 +424,6 @@ find_xml="""<?xml version="1.0" encoding="utf-8" ?>
urlregex=regex.compile('http://\([^:/]+\)\(:[0-9]+\)?\(/.+\)?', regex.casefold) urlregex=regex.compile('http://\([^:/]+\)\(:[0-9]+\)?\(/.+\)?', regex.casefold)
def rfc1123_date(ts=None):
# Return an RFC 1123 format date string, required for
# use in HTTP Date headers per the HTTP 1.1 spec.
if ts is None: ts=time.time()
ts=time.asctime(time.gmtime(ts))
ts=string.split(ts)
return '%s, %s %s %s %s GMT' % (ts[0],ts[2],ts[1],ts[4],ts[3])
def marshal_string(name, val): def marshal_string(name, val):
return '%s=%s' % (name, quote(str(val))) return '%s=%s' % (name, quote(str(val)))
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
"""Commonly used functions for WebDAV support modules.""" """Commonly used functions for WebDAV support modules."""
__version__='$Revision: 1.6 $'[11:-2] __version__='$Revision: 1.7 $'[11:-2]
import string, time, urllib import string, time, urllib
...@@ -120,13 +120,25 @@ def is_acquired(ob): ...@@ -120,13 +120,25 @@ def is_acquired(ob):
return 0 return 0
return 1 return 1
def rfc1123_date(ts=None):
def iso8601_date(ts=None, format='%Y-%m-%dT%H:%M:%SZ'):
# Return an ISO 8601 formatted date string, required
# for certain DAV properties.
#1997-12-01T17:42:21-08:00
#Monday, 12-Jan-98 09:25:56 GMT
if ts is None: ts=time.time()
return time.strftime(format, time.gmtime(ts))
def rfc850_date(ts=None, format='%A, %d-%b-%y %H:%M:%S GMT'):
# Return an HTTP-date formatted date string.
if ts is None: ts=time.time()
return time.strftime(format, time.gmtime(ts))
def rfc1123_date(ts=None, format='%a, %d %b %Y %H:%M:%S GMT'):
# 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.
if ts is None: ts=time.time() if ts is None: ts=time.time()
ts=time.asctime(time.gmtime(ts)) return time.strftime(format, time.gmtime(ts))
ts=string.split(ts)
return '%s, %s %s %s %s GMT' % (ts[0],ts[2],ts[1],ts[4],ts[3])
def urlbase(url, ftype=urllib.splittype, fhost=urllib.splithost): def urlbase(url, ftype=urllib.splittype, fhost=urllib.splithost):
......
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