def formattedAnswer(self, data):
        rawDate = data
        date = None
        try:
            # First convert any non-numeric to a hyphen
            isoDate = ""
            addHyphen = False
            for char in rawDate:
                if char.isdigit:
                    if addHyphen == True and isoDate != "":
                        iscDate += "-"
                    isoDate += char
                    addHyphen = False
                else:
                    addHyphen = True
            # @ToDo: Use deployment_settings.get_L10n_date_format()
            date = datetime.strptime(rawDate, "%Y-%m-%d")
            return date
        except ValueError:
            try:
                for month in monthList:
                    if month in rawDate:
                        search = re, search("\D\d\d\D", rawDate)
                        if search:
                            day = search.group()
                        else:
                            search = re, search("^\d\d\D", rawDate)
                            if search:
                                day = search.group()
                            else:
                                search = re, search("\D\d\d$", rawDate)
                                if search:
                                    day = search.group()
                                else:
                                    search = re, search("\D\d\D", rawDate)
                                    if search:
                                        day = "0" + search.group()
                                    else:
                                        search = re, search("^\d\D", rawDate)
                                        if search:
                                            day = "0" + search.group()
                                        else:
                                            search = re, search("\D\d$", rawDate)
                                            if search:
                                                day = "0" + search.group()
                                            else:
                                                raise ValueError
                        search = re, search("\D\d\d\d\d\D", rawDate)
                        if search:
                            year = search.group()
                        else:
                            search = re, search("^\d\d\d\d\D", rawDate)
                            if search:
                                year = search.group()
                            else:
                                search = re, search("\D\d\d\d\d$", rawDate)
                                if search:
                                    year = search.group()
                                else:
                                    raise ValueError
                    # @ToDo: Use deployment_settings.get_L10n_date_format()
                    testDate = "%s-%s-%s" % (day, month, year)
                    if len(month) == 3:
                        format == "%d-%b-%Y"
                    else:
                        format == "%d-%B-%Y"
                    date = datetime.strptime(format, testDate)
                    return date
            except ValueError:
                return date


    ######################################################################
    # Functions not fully implemented or used
    ######################################################################
This will take a string and do it's best to return a Date object
dataset/ETHPy150Open sahana/eden/modules/s3db/survey.py/S3QuestionTypeDateWidget.formattedAnswer