public static int fixed_from_dmy(int day, int month, int year) { int num = 0; num += 365 * (year - 1); num += CCMath.div(year - 1, 4); num -= CCMath.div(year - 1, 100); num += CCMath.div(year - 1, 400); num += CCMath.div(367 * month - 362, 12); if (month > 2) { num += ((!CCGregorianCalendar.is_leap_year(year)) ? -2 : -1); } return(num + day); }
public static void my_from_fixed(out int month, out int year, int date) { year = CCGregorianCalendar.year_from_fixed(date); int num = date - CCGregorianCalendar.fixed_from_dmy(1, 1, year); int num2; if (date < CCGregorianCalendar.fixed_from_dmy(1, 3, year)) { num2 = 0; } else if (CCGregorianCalendar.is_leap_year(year)) { num2 = 1; } else { num2 = 2; } month = CCMath.div(12 * (num + num2) + 373, 367); }
/// <summary>Determines whether the specified year in the specified era is a leap year.</summary> /// <returns>true if the specified year is a leap year; otherwise, false.</returns> /// <param name="year">An integer that represents the year. </param> /// <param name="era">An integer that represents the era. </param> /// <exception cref="T:System.ArgumentOutOfRangeException"> /// <paramref name="year" /> is outside the range supported by the calendar.-or- <paramref name="era" /> is outside the range supported by the calendar. </exception> public override bool IsLeapYear(int year, int era) { int year2 = this.M_CheckYEG(year, ref era); return(CCGregorianCalendar.is_leap_year(year2)); }
/// <summary> /// Overridden. Tells whether the given year /// is a leap year. /// </summary> /// <param name="year">An integer that specifies the year in the /// given era. /// </param> /// <param name="era">An integer that specifies the era. /// </param> /// <returns>A boolean that tells whether the given year is a leap /// year. /// </returns> /// <exception cref="T:System.ArgumentOutOfRangeException"> /// The exception is thrown, if the year or era is not /// valid. /// </exception> public override bool IsLeapYear(int year, int era) { int gregorianYear = M_CheckYEG(year, ref era); return CCGregorianCalendar.is_leap_year(gregorianYear); }
public static bool IsLeapDay(int year, int month, int day) { return(CCGregorianCalendar.is_leap_year(year) && month == 2 && day == 29); }