diff options
author | rhoerbe <rainer@hoerbe.at> | 2014-03-21 14:13:56 +0100 |
---|---|---|
committer | rhoerbe <rainer@hoerbe.at> | 2014-03-21 14:13:56 +0100 |
commit | bbb01cdbc2c88b6ab5211b3ff956693c95bbc5d6 (patch) | |
tree | d4af29a7e7f293c68069428343534ba22c031a35 /src/saml2/httpbase.py | |
parent | 73699f337d6c8daac24e1f70caa36e5dcd3b5ff7 (diff) | |
download | pysaml2-bbb01cdbc2c88b6ab5211b3ff956693c95bbc5d6.tar.gz |
added support for RFC 1123 date format
Diffstat (limited to 'src/saml2/httpbase.py')
-rw-r--r-- | src/saml2/httpbase.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/saml2/httpbase.py b/src/saml2/httpbase.py index 3b6b630d..8c99c95d 100644 --- a/src/saml2/httpbase.py +++ b/src/saml2/httpbase.py @@ -69,9 +69,18 @@ def _since_epoch(cdate): cdate = cdate[5:] try: - t = time.strptime(cdate, "%d-%b-%Y %H:%M:%S %Z") + t = time.strptime(cdate, "%d-%b-%Y %H:%M:%S %Z") # e.g. 18-Apr-2014 12:30:51 GMT except ValueError: - t = time.strptime(cdate, "%d-%b-%y %H:%M:%S %Z") + try: + t = time.strptime(cdate, "%d-%b-%y %H:%M:%S %Z") # e.g. 18-Apr-14 12:30:51 GMT + except ValueError: + try: + t = time.strptime(cdate, "%d %b %Y %H:%M:%S %Z") # e.g. 18 Apr 2014 12:30:51 GMT + except ValueError: + raise Exception, 'ValueError: Date "{0}" does not match any of '.format(cdate) + \ + '"%d-%b-%Y %H:%M:%S %Z", ' + \ + '"%d-%b-%y %H:%M:%S %Z", ' + \ + '"%d %b %Y %H:%M:%S %Z".' #return int(time.mktime(t)) return calendar.timegm(t) |