Commits

Andriy Kornatskyy  committed c2c0ef1

Introduced parse_http_datetime function

  • Participants
  • Parent commits cce1c8f

Comments (0)

Files changed (1)

File src/wheezy/core/datetime.py

 
 """ ``datetime`` module.
 """
+
 from time import gmtime
 from time import localtime
 from time import mktime
 
+from wheezy.core.comp import parsedate
 from wheezy.core.introspection import import_name
 
 # The lines below are equivalent to:
     )
 
 
+def parse_http_datetime(stamp):
+    """
+        >>> parse_http_datetime('Mon, 19 Sep 2011 10:45:30 GMT')
+        datetime.datetime(2011, 9, 19, 10, 45, 30)
+    """
+    return datetime.fromtimestamp(mktime(parsedate(stamp)))
+
+
 def total_seconds(delta):
     """ Returns a total number of seconds for the given delta.