Added http_date utility function
parent
b50ca751fb
commit
dd05d95dba
|
@ -21,6 +21,10 @@ Please give me a docstring!
|
||||||
:Updater: $Author$
|
:Updater: $Author$
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
from wsgiref.handlers import format_date_time
|
||||||
|
import datetime
|
||||||
|
import time
|
||||||
|
|
||||||
def asbool(val):
|
def asbool(val):
|
||||||
'''Test a value for truth
|
'''Test a value for truth
|
||||||
|
|
||||||
|
@ -46,4 +50,19 @@ def asbool(val):
|
||||||
pass
|
pass
|
||||||
if val in ('false', 'no', 'f', 'n', 'off', '0'):
|
if val in ('false', 'no', 'f', 'n', 'off', '0'):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def http_date(date):
|
||||||
|
'''Format a datetime object as a string in RFC 1123 format
|
||||||
|
|
||||||
|
This function returns a string representing the date according to
|
||||||
|
RFC 1123. The string returned will always be in English, as
|
||||||
|
required by the specification.
|
||||||
|
|
||||||
|
:param date: A :py:class:`datetime.datetime` object
|
||||||
|
:return: RFC 1123-formatted string
|
||||||
|
'''
|
||||||
|
|
||||||
|
stamp = time.mktime(date.timetuple())
|
||||||
|
return format_date_time(stamp)
|
||||||
|
|
Loading…
Reference in New Issue