js方法判断某年某月有几天

function fanDayByYearMonth(year,month) {
  switch (month) {
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12:
      return 31;
      break;
    case 2:
      return isRunYear(year) ? 29 : 28;
      break;
    case 4:
    case 6:
    case 9:
    case 11:
      return 30;
      break;
  }
}
//被四整除(不被100整除)的是闰年,其中可以被100整除的同时必须被400整除的才是闰年,其余的就是平年
function isRunYear(year) {
  if (year % 4 == 0) {
    if (year % 100 ) {
      if (year % 400 == 0) {
        return true;
      }else{
        return false;
      }
    }
    return true;
  }else{
    return false;
  }
}
function isRunYears(year) {
  return year%4== 0? (year%100 == 0? (year%400==0? true:false) :true) : false;
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容