编程之路

——火地晋

  :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
/// <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;
}

 

posted on 2010-09-02 11:06  火地晋  阅读(352)  评论(1编辑  收藏  举报