X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=python%2Fashd%2Fwsgiutil.py;h=711435f525f1d701936e3a2e5990d086a0874239;hb=595adb9922885c2a05bc6917ee8f8f02f496e618;hp=5fe7535140eafc6ae08246126d0cb761656e995c;hpb=55fa3f634594cedabf75182bd6404463c091ff63;p=ashd.git diff --git a/python/ashd/wsgiutil.py b/python/ashd/wsgiutil.py index 5fe7535..711435f 100644 --- a/python/ashd/wsgiutil.py +++ b/python/ashd/wsgiutil.py @@ -1,3 +1,5 @@ +import time + def htmlquote(text): ret = "" for c in text: @@ -25,6 +27,17 @@ def simpleerror(env, startreq, code, title, msg):

%s

""" % (title, title, htmlquote(msg)) - buf = buf.encode("ascii") startreq("%i %s" % (code, title), [("Content-Type", "text/html"), ("Content-Length", str(len(buf)))]) return [buf] + +def httpdate(ts): + return time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime(ts)) + +def phttpdate(dstr): + tz = dstr[-6:] + dstr = dstr[:-6] + if tz[0] != " " or (tz[1] != "+" and tz[1] != "-") or not tz[2:].isdigit(): + return None + tz = int(tz[1:]) + tz = (((tz / 100) * 60) + (tz % 100)) * 60 + return time.mktime(time.strptime(dstr, "%a, %d %b %Y %H:%M:%S")) - tz - time.altzone