Skip to content

Commit bbb01cd

Browse files
committed
added support for RFC 1123 date format
1 parent 73699f3 commit bbb01cd

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/saml2/httpbase.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,18 @@ def _since_epoch(cdate):
6969

7070
cdate = cdate[5:]
7171
try:
72-
t = time.strptime(cdate, "%d-%b-%Y %H:%M:%S %Z")
72+
t = time.strptime(cdate, "%d-%b-%Y %H:%M:%S %Z") # e.g. 18-Apr-2014 12:30:51 GMT
7373
except ValueError:
74-
t = time.strptime(cdate, "%d-%b-%y %H:%M:%S %Z")
74+
try:
75+
t = time.strptime(cdate, "%d-%b-%y %H:%M:%S %Z") # e.g. 18-Apr-14 12:30:51 GMT
76+
except ValueError:
77+
try:
78+
t = time.strptime(cdate, "%d %b %Y %H:%M:%S %Z") # e.g. 18 Apr 2014 12:30:51 GMT
79+
except ValueError:
80+
raise Exception, 'ValueError: Date "{0}" does not match any of '.format(cdate) + \
81+
'"%d-%b-%Y %H:%M:%S %Z", ' + \
82+
'"%d-%b-%y %H:%M:%S %Z", ' + \
83+
'"%d %b %Y %H:%M:%S %Z".'
7584
#return int(time.mktime(t))
7685
return calendar.timegm(t)
7786

0 commit comments

Comments
 (0)