判断两个时间间隔是否是自然月

 1  /// <summary>
 2         ///  判断两个时间间隔是否是自然月
 3         /// </summary>
 4         /// <param name="date1"></param>
 5         /// <param name="date2"></param>
 6         /// <returns></returns>
 7         public static bool isNaturalMonth(DateTime date1, DateTime date2)
 8         {
 9             int startYear = date1.Year;
10             int startMonth = date1.Month;
11             int startDay = date1.Day;
12             int endYear = date2.Year;
13             int endMonth = date2.Month;
14             int endDay = date2.Day;
15 
16             if (startYear != endYear)
17             {
18                 return false;
19             }
20             if (startMonth != endMonth)
21             {
22                 return false;
23             }
24 
25             if (startDay == 1)
26             {
27                 if (endMonth == 2)
28                 {
29                     if (endYear % 4 == 0 && endYear % 100 != 0 || endYear % 400 == 0)
30                     {
31                         if (endDay == 29)
32                             return true;
33                     }
34                     else
35                     {
36                         if (endDay == 28)
37                             return true;
38                     }
39                 }
40                 else
41                 {
42                     if (endMonth == 1 || endMonth == 3 || endMonth == 5 || endMonth == 7 || endMonth == 8 || endMonth == 10 || endMonth == 12)
43                     {
44                         if (endDay == 31)
45                             return true;
46                     }
47                     else
48                     {
49                         if (endDay == 30)
50                             return true;
51                     }
52                 }
53             }
54             return false;
55 
56 
57         }

 

判断两个时间间隔是否是自然月

上一篇:ARM Cortex-M7处理器体系结构简介


下一篇:link标签rel="alternate"属性