@check.implementation(To)
def To_check(to_date):
    to_date.errors = []
    error = to_date.errors.append
    year = to_date.year
    if to_date.month is None:
        month = 12
    else:
        month = to_date.month
    if to_date.day is None:
        day = -1
    else:
        day = to_date.day
    if not isinstance(year, int):
        error("Year should be a whole number")
    if not isinstance(day, int):
        error("Day should be a whole number")
    if not (1900 < year < 2500):
        error("Year should be in range 1900 to 2500")
    month_number = month_number_from_arg(month, error)
    if day is -1:
        # use last day of month
        _, day = calendar.monthrange(year, month_number)
    try:
        to_date.date = datetime.date(year, month_number, day)
    except __HOLE__:
        error("Invalid date: datetime.date(%i, %i, %i)" % (year, month_number, day))
    return to_date.errors
dataset/ETHPy150Open sahana/eden/modules/ClimateDataPortal/DSL/Check.py/To_check