/// <summary>Calculates a date that is a specified number of months away from a specified initial date.</summary>
/// <param name="time">The date to which to add months. The <see cref="T:System.Globalization.UmAlQuraCalendar" /> class supports only dates from 04/30/1900 00.00.00 (Gregorian date) through 11/16/2077 23:59:59 (Gregorian date).</param>
/// <param name="months">The positive or negative number of months to add. </param>
/// <returns>The date yielded by adding the number of months specified by the <paramref name="months" /> parameter to the date specified by the <paramref name="time" /> parameter.</returns>
/// <exception cref="T:System.ArgumentException">The resulting date is outside the range supported by the <see cref="T:System.Globalization.UmAlQuraCalendar" /> class. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="months" /> is less than -120,000 or greater than 120,000. -or-
/// <paramref name="time" /> is outside the range supported by this calendar.</exception>
// Token: 0x06002ED8 RID: 11992 RVA: 0x000B3E20 File Offset: 0x000B2020
public override DateTime AddMonths(DateTime time, int months)
{
if (months < -120000 || months > 120000)
{
throw new ArgumentOutOfRangeException("months", string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), -120000, 120000));
}
int num = this.GetDatePart(time, 0);
int num2 = this.GetDatePart(time, 2);
int num3 = this.GetDatePart(time, 3);
int num4 = num2 - 1 + months;
if (num4 >= 0)
{
num2 = num4 % 12 + 1;
num += num4 / 12;
}
else
{
num2 = 12 + (num4 + 1) % 12;
num += (num4 - 11) / 12;
}
if (num3 > 29)
{
int daysInMonth = this.GetDaysInMonth(num, num2);
if (num3 > daysInMonth)
{
num3 = daysInMonth;
}
}
UmAlQuraCalendar.CheckYearRange(num, 1);
DateTime result = new DateTime(UmAlQuraCalendar.GetAbsoluteDateUmAlQura(num, num2, num3) * 864000000000L + time.Ticks % 864000000000L);
Calendar.CheckAddResult(result.Ticks, this.MinSupportedDateTime, this.MaxSupportedDateTime);
return(result);
}