@staticmethod<EOL><INDENT>def clean(date, ignore_time=False):<DEDENT>
<EOL>if not date:<EOL><INDENT>return date<EOL><DEDENT>parts = re.split(r'<STR_LIT>', date)<EOL>if (len(parts) == <NUM_LIT:3>) or(len(parts) > <NUM_LIT:3> and ignore_time) or(len(parts) == <NUM_LIT:4> and re.match(r'<STR_LIT>', parts[<NUM_LIT:3>])) or(len(parts) == <NUM_LIT:5> and re.match(r'<STR_LIT>', parts[<NUM_LIT:3>]) and re.match(r'<STR_LIT>', parts[<NUM_LIT:4>])):<EOL><INDENT>if len(parts[<NUM_LIT:0>]) == <NUM_LIT:4> and len(parts[<NUM_LIT:1>]) <= <NUM_LIT:2> and len(parts[<NUM_LIT:2>]) <= <NUM_LIT:2>:<EOL><INDENT>return parts[<NUM_LIT:0>] + '<STR_LIT:->' + ('<STR_LIT>' + parts[<NUM_LIT:1>])[-<NUM_LIT:2>:] + '<STR_LIT:->' + ('<STR_LIT>' + parts[<NUM_LIT:2>])[-<NUM_LIT:2>:]<EOL><DEDENT>if len(parts[<NUM_LIT:0>]) <= <NUM_LIT:2> and len(parts[<NUM_LIT:1>]) <= <NUM_LIT:2> and len(parts[<NUM_LIT:2>]) == <NUM_LIT:4>:<EOL><INDENT>return parts[<NUM_LIT:2>] + '<STR_LIT:->' + ('<STR_LIT>' + parts[<NUM_LIT:1>])[-<NUM_LIT:2>:] + '<STR_LIT:->' + ('<STR_LIT>' + parts[<NUM_LIT:0>])[-<NUM_LIT:2>:]<EOL><DEDENT>if len(parts[<NUM_LIT:0>]) <= <NUM_LIT:2> and len(parts[<NUM_LIT:1>]) <= <NUM_LIT:2> and len(parts[<NUM_LIT:2>]) == <NUM_LIT:2>:<EOL><INDENT>year = '<STR_LIT>' + parts[<NUM_LIT:2>] if parts[<NUM_LIT:2>] >= '<STR_LIT>' else '<STR_LIT>' + parts[<NUM_LIT:2>]<EOL>return year + '<STR_LIT:->' + ('<STR_LIT>' + parts[<NUM_LIT:1>])[-<NUM_LIT:2>:] + '<STR_LIT:->' + ('<STR_LIT>' + parts[<NUM_LIT:0>])[-<NUM_LIT:2>:]<EOL><DEDENT><DEDENT>pattern = r'<STR_LIT>' + ('<STR_LIT>' if ignore_time else r'<STR_LIT>')<EOL>match = re.match(pattern, date.lower())<EOL>if match and match.group(<NUM_LIT:2>) in DateCleaner.month_map:<EOL><INDENT>ret = match.group(<NUM_LIT:3>) + '<STR_LIT:->' + DateCleaner.month_map[match.group(<NUM_LIT:2>)] + '<STR_LIT:->' + match.group(<NUM_LIT:1>)<EOL>if len(match.groups()) == <NUM_LIT:7> and match.group(<NUM_LIT:4>):<EOL><INDENT>ret += '<STR_LIT:T>' + match.group(<NUM_LIT:5>) + '<STR_LIT::>' + match.group(<NUM_LIT:6>) + '<STR_LIT::>' + match.group(<NUM_LIT:7>)<EOL><DEDENT>return ret<EOL><DEDENT>pattern = r'<STR_LIT>' + ('<STR_LIT>' if ignore_time else '<STR_LIT:$>')<EOL>match = re.match(pattern, date)<EOL>if match:<EOL><INDENT>return date[<NUM_LIT:0>:<NUM_LIT:4>] + '<STR_LIT:->' + date[<NUM_LIT:4>:<NUM_LIT:6>] + '<STR_LIT:->' + date[<NUM_LIT:6>:<NUM_LIT:8>]<EOL><DEDENT>return date<EOL>
Converts a date in miscellaneous format to ISO-8601 (YYYY-MM-DD) format.

:param str date: The input date.
:param bool ignore_time: If true any trailing time prt is ignore.

:rtype: str