File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -67,11 +67,20 @@ def _since_epoch(cdate):
67
67
if len (cdate ) < 5 :
68
68
return utc_now ()
69
69
70
- cdate = cdate [5 :]
70
+ cdate = cdate [5 :] # assume short weekday, i.e. do not support obsolete RFC 1036 date format
71
71
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
73
73
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".'
75
84
#return int(time.mktime(t))
76
85
return calendar .timegm (t )
77
86
You can’t perform that action at this time.
0 commit comments