dabo Commit
Revision 4237
Date: 2008-07-04 17:19:43 -0700 (Fri, 04 Jul 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4237
Changed:
U trunk/dabo/lib/dates.py
Log:
Added the 'webHeaderFormat()' method that takes a datetime value and returns a
formatted string that conforms with the standard expected by HTTP headers.
Diff:
Modified: trunk/dabo/lib/dates.py
===================================================================
--- trunk/dabo/lib/dates.py 2008-07-05 00:06:29 UTC (rev 4236)
+++ trunk/dabo/lib/dates.py 2008-07-05 00:19:43 UTC (rev 4237)
@@ -265,6 +265,17 @@
return datetime.date(new_time[0], new_time[1], new_time[2])
+def webHeaderFormat(dtm):
+ """Takes a datetime value and returns a string in the format required
by
+ HTTP headers, such as an 'If-Modified-Since' header.
+ """
+ hereNow, utcNow = datetime.datetime.now(), datetime.datetime.utcnow()
+ offset = utcNow - hereNow
+ adjusted = dtm + offset
+ return adjusted.strftime("%a, %d %b %Y %H:%M:%S GMT")
+
+
+
if __name__ == "__main__":
print "testing converting strings to dates:"
formats = ["ISO8601", "YYYYMMDD", "YYMMDD", "MMDD"]
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]