获取某月最大天数
参数:y = year,m = month
返回:len = 31/30/29/28
function(y, m) {
var len = m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12 ? 31 : m == 4 || m == 6 || m == 9 || m == 11 ? 30 : y % 4 == 0 && y % 100 != 0 ? 29 : y % 400 == 0 ? 29 : 28
return len
}
function(y, m) {
var len =0;
if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
len = 31;
} else if (m == 4 || m == 6 || m == 9 || m == 11) {
len = 30;
} else {
if (y % 4 == 0 && y % 100 != 0) {
len = 29;
} else if (y % 400 == 0) {
len = 29;
} else {
len = 28;
}
}
return len
}
网友评论