/// <summary>
/// 返回月份拥有的天数
/// </summary>
/// <param name="month"></param>
/// <param name="year"></param>
/// <returns></returns>
public static int GetLastDay(int month, int year)
{

    
switch (month)
    {
        
case 1:
        
case 3:
        
case 5:
        
case 7:
        
case 8:
        
case 10:
        
case 12:
            
return 31;
        
case 2:
            
return year % 100 != 0 && year % 4 == 0 || year % 400 == 0 ? 29 : 28;
        
case 4:
        
case 6:
        
case 9:
        
case 11:
            
return 30;
    }
    
return -1;
}

 

相关文章: