@qrvey/formula-lang
Version:
QFormula support for qrvey projects
22 lines • 700 B
JavaScript
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
*/
export 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];
}
}
//# sourceMappingURL=getMonthMaxDayAllowed.js.map