from datetime import datetime


def date_check(y, m, d):
    """Ensure that a date is valid."""
    try:
        test = bool(datetime.strptime(f"{y}{m}{d}", "%Y%m%d"))
    except:
        test = False
    return test