Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * 检查平润年,返回正确月份的天数
- * @param year 年份
- * @param month 月份
- * @returns {number} 该月正确的天数
- */
- function checkTime(year, month) {
- if (month === 2) return (year % 4 === 0 && year % 100 !== 0 || year % 400) === 0 ? 29 : 28;
- return '4;6;9;11'.indexOf(month + ';') === -1 ? 31 : 30;
- }
- document.write(checkTime(2017,2));
- //最终打印出28
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement