System.Globalization.Calendar.GetLeapMonth C# (CSharp) Method

GetLeapMonth() private method

private GetLeapMonth ( int year, int era ) : int
year int
era int
return int
        public virtual int GetLeapMonth(int year, int era)
        {
            if (!IsLeapYear(year, era))
                return 0;

            int monthsCount = GetMonthsInYear(year, era);
            for (int month=1; month<=monthsCount; month++)
            {
                if (IsLeapMonth(year, month, era))
                    return month;
            }

            return 0;
        }

Same methods

Calendar::GetLeapMonth ( int year ) : int

Usage Example

 public static void GetLeapMonthTest(Calendar calendar, int yearHasLeapMonth, CalendarAlgorithmType algorithmType)
 {
     if (yearHasLeapMonth > 0)
     {
         Assert.NotEqual(calendar.GetLeapMonth(yearHasLeapMonth),  0);
         Assert.Equal(0, calendar.GetLeapMonth(yearHasLeapMonth - 1));
     }
     else
         Assert.True(calendar.GetLeapMonth(calendar.GetYear(DateTime.Today)) == 0, 
                     "calendar.GetLeapMonth returned wrong value");
 }