GetAbsoluteDateUmAlQura() private method

private GetAbsoluteDateUmAlQura ( int year, int month, int day ) : long
year int
month int
day int
return long
        // Token: 0x06002ED7 RID: 11991 RVA: 0x000B3DB8 File Offset: 0x000B1FB8
        internal virtual int GetDatePart(DateTime time, int part)
        {
            int  num   = 0;
            int  num2  = 0;
            int  num3  = 0;
            long ticks = time.Ticks;

            UmAlQuraCalendar.CheckTicksRange(ticks);
            UmAlQuraCalendar.ConvertGregorianToHijri(time, ref num, ref num2, ref num3);
            if (part == 0)
            {
                return(num);
            }
            if (part == 2)
            {
                return(num2);
            }
            if (part == 3)
            {
                return(num3);
            }
            if (part == 1)
            {
                return((int)(UmAlQuraCalendar.GetAbsoluteDateUmAlQura(num, num2, num3) - UmAlQuraCalendar.GetAbsoluteDateUmAlQura(num, 1, 1) + 1L));
            }
            throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_DateTimeParsing"));
        }
        /// <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);
        }
        /// <summary>Returns a <see cref="T:System.DateTime" /> that is set to the specified date, time, and era.</summary>
        /// <param name="year">A year. </param>
        /// <param name="month">An integer from 1 through 12 that represents a month. </param>
        /// <param name="day">An integer from 1 through 29 that represents a day. </param>
        /// <param name="hour">An integer from 0 through 23 that represents an hour. </param>
        /// <param name="minute">An integer from 0 through 59 that represents a minute. </param>
        /// <param name="second">An integer from 0 through 59 that represents a second. </param>
        /// <param name="millisecond">An integer from 0 through 999 that represents a millisecond. </param>
        /// <param name="era">An era. Specify <see langword="UmAlQuraCalendar.Eras[UmAlQuraCalendar.CurrentEra]" /> or <see cref="F:System.Globalization.UmAlQuraCalendar.UmAlQuraEra" />.</param>
        /// <returns>The <see cref="T:System.DateTime" /> that is set to the specified date and time in the current era.</returns>
        /// <exception cref="T:System.ArgumentOutOfRangeException">
        ///         <paramref name="year" />, <paramref name="month" />, <paramref name="day" />, or <paramref name="era" /> is outside the range supported by the <see cref="T:System.Globalization.UmAlQuraCalendar" /> class.-or-
        ///         <paramref name="hour" /> is less than zero or greater than 23.-or-
        ///         <paramref name="minute" /> is less than zero or greater than 59.-or-
        ///         <paramref name="second" /> is less than zero or greater than 59.-or-
        ///         <paramref name="millisecond" /> is less than zero or greater than 999. </exception>
        // Token: 0x06002EE9 RID: 12009 RVA: 0x000B40A4 File Offset: 0x000B22A4
        public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era)
        {
            if (day >= 1 && day <= 29)
            {
                UmAlQuraCalendar.CheckYearMonthRange(year, month, era);
            }
            else
            {
                int daysInMonth = this.GetDaysInMonth(year, month, era);
                if (day < 1 || day > daysInMonth)
                {
                    throw new ArgumentOutOfRangeException("day", string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Day"), daysInMonth, month));
                }
            }
            long absoluteDateUmAlQura = UmAlQuraCalendar.GetAbsoluteDateUmAlQura(year, month, day);

            if (absoluteDateUmAlQura >= 0L)
            {
                return(new DateTime(absoluteDateUmAlQura * 864000000000L + Calendar.TimeToTicks(hour, minute, second, millisecond)));
            }
            throw new ArgumentOutOfRangeException(null, Environment.GetResourceString("ArgumentOutOfRange_BadYearMonthDay"));
        }