def format_date(date_string, OUTPUT_FORMAT, localize=None):
    if date_string is None or date_string == '' or date_string == " " or date_string == EMPTY_FIELD \
            or isinstance(date_string, (int, float)):
        return ''

    if isinstance(date_string, basestring):
        try:
            date_string = dateutil.parser.parse(date_string)
        except (AttributeError, __HOLE__):
            return ''

    if localize:
        tz = Domain.get_by_name(SUCCEED_DOMAIN).get_default_timezone()
        if date_string.tzname() is None:
            date_string = timezone('UTC').localize(date_string)
        date_string = date_string.astimezone(tz)

    return date_string.strftime(OUTPUT_FORMAT)
dataset/ETHPy150Open dimagi/commcare-hq/custom/succeed/utils.py/format_date