30_Js根据年和月获取该月有几天

js根据年和月获取该月有几天:

/**
 * 判断某年是否瑞年
 */
function isRuinian(year){
       if(year/4 == 0 && year/100 != 0){
               return true ;
       } else if (year/400 == 0){
               return true ;
       } else{
               return false ;
       }
};

/**
 * 根据年和月获取该月有几天
 */
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:
                     $scope.isRuinian(year) ? 29 : 28;
       }
};

猜你喜欢

转载自blog.csdn.net/zs345048102/article/details/81461130
今日推荐