src/js/formatDate.js
function isValidDate(year, month, date) { // eslint-disable-line complexity
    var isValidYear, isValidMonth, isValid, lastDayInMonth;

    year = Number(year);
    month = Number(month);
    date = Number(date);

    isValidYear = (year > -1 && year < 100) || ((year > 1969) && (year < 2070));
    isValidMonth = (month > 0) && (month < 13);

    if (!isValidYear || !isValidMonth) {
        return false;
    }

    lastDayInMonth = MONTH_DAYS[month];
    if (month === 2 && year % 4 === 0) {
        if (year % 100 !== 0 || year % 400 === 0) {
            lastDayInMonth = 29;
        }
    }

    isValid = (date > 0) && (date <= lastDayInMonth);

    return isValid;
}
function isValidDate(year, month, date) { // eslint-disable-line complexity
    var isValidYear, isValidMonth, isValid, lastDayInMonth;

    year = Number(year);
    month = Number(month);
    date = Number(date);

    isValidYear = (year > -1 && year < 100) || ((year > 1969) && (year < 2070));
    isValidMonth = (month > 0) && (month < 13);

    if (!isValidYear || !isValidMonth) {
        return false;
    }

    lastDayInMonth = MONTH_DAYS[month];
    if (month === 2 && year % 4 === 0) {
        if (year % 100 !== 0 || year % 400 === 0) {
            lastDayInMonth = 29;
        }
    }

    isValid = (date > 0) && (date <= lastDayInMonth);

    return isValid;
}
function isValidDate ( year , month , date ) { // eslint-disable-line complexity var isValidYear , isValidMonth , isValid , lastDayInMonth ; year = Number ( year ) ; month = Number ( month ) ; date = Number ( date ) ; isValidYear = ( year > - 1 && year < 100 ) || ( ( year > 1969 ) && ( year < 2070 ) ) ; isValidMonth = ( month > 0 ) && ( month < 13 ) ; if ( ! isValidYear || ! isValidMonth ) { return false ; } lastDayInMonth = MONTH_DAYS [ month ] ; if ( month === 2 && year % 4 === 0 ) { if ( year % 100 !== 0 || year % 400 === 0 ) { lastDayInMonth = 29 ; } } isValid = ( date > 0 ) && ( date <= lastDayInMonth ) ; return isValid ; }
Check whether the given variables are valid date or not.
@param {number} year - Year
@param {number} month - Month
@param {number} date - Day in month.
@returns {boolean} Is valid?
@private
Check whether the given variables are valid date or not .