在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
年份:1900——今年 月份:大小月 天数:是否是闰月天数 1 /// <summary>判断生日格式是否正确</summary> 2 /// <returns></returns> 3 public static bool CheckBirthDay(DateTime date) 4 { 5 int[] bigMonth = { 1, 3, 5, 7, 8, 10, 12 }; 6 int[] smallMonth = { 2, 4, 6, 9, 11 }; 7 if (date.Year < 1900 || date.Year > DateTime.Now.Year) return false; 8 if (date.Month > 13 || date.Month < 1) return false; 9 if (date.Day < 1) return false; 10 for (int i = 0; i < bigMonth.Length; i++) 11 { 12 if (date.Month == bigMonth[i]) 13 if (date.Day > 31) return false; 14 } 15 for (int i = 0; i < smallMonth.Length; i++) 16 { 17 if (date.Month == smallMonth[i]) 18 if (date.Day > 30) return false; 19 } 20 if (date.Month == 2) 21 { 22 if (IsLeap(date.Year)) 23 { 24 if (date.Day > 29) return false; 25 } 26 else 27 if (date.Day > 28) return false; 28 } 29 return true; 30 } 31 32 /// <summary>判断是否为闰年,四年一闰,百年不闰,四百年再闰</summary> 33 /// <param name="yN"></param> 34 /// <returns></returns> 35 public static bool IsLeap(int yN) 36 { 37 if ((yN % 400 == 0 && yN % 3200 != 0) 38 || (yN % 4 == 0 && yN % 100 != 0) 39 || (yN % 3200 == 0 && yN % 172800 == 0)) 40 return true; 41 else 42 return false; 43 } |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论