Asp.Net判断某年某月总天数

Controllers

public static int GetDays(int year, int month)  
      {  
          int[] days = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };  
          if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))  
          {  
              return 29;  
          }  
          else if (month == 2)  
          {  
              month = 1;  
              return days[month];  
          }  
          else  
          {  
              month = month - 1;  
              return days[month];  
          }  
      } 

调用

GetDays(year, month);  

 

posted @ 2016-11-02 20:33  MiloCui  阅读(204)  评论(0)    收藏  举报