UNPKG

@qrvey/formula-lang

Version:

QFormula support for qrvey projects

26 lines 865 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getMonthMaxDayAllowed = void 0; function isLeapYear(year) { return year % 4 === 0 && year % 100 !== 0; } const MONTH_MAX_DAYS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; /** * Gets the max number of days allowed for a date * @param month 0 index month of the year * @param year year of a date * @returns number with the max number allowed. -1 if month does not exist in array list */ function getMonthMaxDayAllowed(month, year) { if (month > 11 || month < 0) return -1; if (month === 1) { // case for february return isLeapYear(year) ? 29 : MONTH_MAX_DAYS[month]; } else { return MONTH_MAX_DAYS[month]; } } exports.getMonthMaxDayAllowed = getMonthMaxDayAllowed; //# sourceMappingURL=getMonthMaxDayAllowed.js.map