Merge pull request #98 from rhoerbe/master
added support for RFC 1123 date format
This commit is contained in:
@@ -67,11 +67,20 @@ def _since_epoch(cdate):
|
||||
if len(cdate) < 5:
|
||||
return utc_now()
|
||||
|
||||
cdate = cdate[5:]
|
||||
cdate = cdate[5:] # assume short weekday, i.e. do not support obsolete RFC 1036 date format
|
||||
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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user