2009-02-16 [.NET C#] 計算閏年方式 6132 0 .Net C# 2009-04-16 摘要:[.NET C#] 計算閏年方式 //startdate起始日期,enddate結束日期 public static int GetBissextile(DateTime startdate, DateTime enddate) { int functionReturnValue = 0; int A_year = DatePart(DateInterval.Year, startdate); int B_year = DatePart(DateInterval.Year, enddate); int A_B_Count = B_year - A_year + 1; for (int i = 0; i <= A_B_Count; i++) { if ((A_year % 3200 == 0) && (A_year % 400 == 0) || ((A_year % 4 == 0) && (A_year % 100 != 0))) { functionReturnValue += 1; } A_year += 1; } return functionReturnValue; } ASP.NETC# 回首頁