@staticmethod<EOL><INDENT>def parse_date(date_str):<DEDENT>
months = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>formats = {<EOL>r'<STR_LIT>':<EOL>lambda m: '<STR_LIT>'.format(<EOL>m.group(<NUM_LIT:3>),<EOL>months.index(m.group(<NUM_LIT:2>).lower())+<NUM_LIT:1>,<EOL>m.group(<NUM_LIT:1>)),<EOL>r'<STR_LIT>':<EOL>lambda m: '<STR_LIT>'.format(<EOL>str(datetime.date.today().year)[:<NUM_LIT:2>],<EOL>m.group(<NUM_LIT:3>),<EOL>months.index(m.group(<NUM_LIT:2>).lower())+<NUM_LIT:1>,<EOL>m.group(<NUM_LIT:1>)),<EOL>r'<STR_LIT>':<EOL>lambda m: '<STR_LIT>'.format(<EOL>m.group(<NUM_LIT:3>),<EOL>months.index(m.group(<NUM_LIT:1>).lower())+<NUM_LIT:1>,<EOL>int(m.group(<NUM_LIT:2>))),<EOL>r'<STR_LIT>':<EOL>lambda m: '<STR_LIT>'.format(*m.groups()),<EOL>r'<STR_LIT>':<EOL>lambda m: m.group(<NUM_LIT:1>),<EOL>}<EOL>out_date = None<EOL>for regex, xform in formats.items():<EOL><INDENT>m = re.search(regex, date_str)<EOL>if m:<EOL><INDENT>out_date = xform(m)<EOL>break<EOL><DEDENT><DEDENT>if out_date is None:<EOL><INDENT>raise DateFormatError<EOL><DEDENT>else:<EOL><INDENT>return out_date<EOL><DEDENT>
Check if date_str is in a recognised format and return an ISO
yyyy-mm-dd format version if so. Raise DateFormatError if not.

Recognised formats are:
* RFC 7231 (e.g. Mon, 09 Sep 2011 23:36:00 GMT)
* RFC 850 (e.g. Sunday, 06-Nov-94 08:49:37 GMT)
* C time (e.g. Wed Dec 4 00:00:00 2002)
* Amz-Date format (e.g. 20090325T010101Z)
* ISO 8601 / RFC 3339 (e.g. 2009-03-25T10:11:12.13-01:00)

date_str -- Str containing a date and optional time