(val)
Forces a date, string, or datetime to a date.
Forces a date, string, or datetime to a date.
Forces a date string or datetime to a date .
def force_to_date(val):
    """Forces a date, string, or datetime to a date."""
    if not val:
        return val
    elif isinstance(val, datetime.datetime):
        return val.date()
    elif isinstance(val, datetime.date):
        return val
    elif isinstance(val, str):
        return string_to_datetime(val).date()
    else:
        raise ValueError("object must be date or datetime!")
def force_to_date ( val ) : if not val : return val elif isinstance ( val , datetime . datetime ) : return val . date ( ) elif isinstance ( val , datetime . date ) : return val elif isinstance ( val , str ) : return string_to_datetime ( val ) . date ( ) else : raise ValueError ( "object must be date or datetime!" )