Tries to extract a date from a given :obj:`str`.

        :param str text: Input date. A :obj:`datetime.date` object is passed
             thought without modification.
        :rtype: :obj:`datetime.date`

def extractDate(text):
    """ Tries to extract a date from a given :obj:`str`.

        :param str text: Input date. A :obj:`datetime.date` object is passed
             thought without modification.
        :rtype: :obj:`datetime.date`"""
    if type(text) is datetime.date:
        return text
    match = date_format.search(text.lower())
    if not match:
        raise ValueError('unsupported date format: {0}'.format(text.lower()))
    # convert DD.MM.YYYY into YYYY-MM-DD
    if match.group('month'):
        if not match.group('month') in month_names:
            raise ValueError('unknown month names: "{0}"'
                             .format(match.group('month')))
        year = int(match.group('year'))
        return datetime.date(
            year if year > 2000 else 2000 + year,
            int(month_names[match.group('month')]),
            int(match.group('day')))
    else:
        parts = list(map(lambda v: int(v), '-'.join(reversed(
            match.group('datestr').split('.'))).split('-')))
        if parts[0] < 2000:
            parts[0] += 2000
        return datetime.date(*parts)