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