JS根据年月获取天数

//根据年月得到天数
function getDayNumByYearMonth(year, month) {
	switch (month) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			return 31;
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			return 30;
			break;
		case 2:
			this.actions.isLeapYear(year) ? 29 : 28;
	}
}

 

//是否是闰年
function isLeapYear(year) {
	if (year / 4 == 0 && year / 100 != 0) {
		return true;
	} else if (year / 400 == 0) {
		return true;
	} else {
		return false;
	}
}

 

posted @ 2019-10-19 15:40  ZhiPeng007  阅读(721)  评论(2编辑  收藏  举报