System.Globalization.HebrewCalendar.CheckHebrewYearValue C# (CSharp) Method

CheckHebrewYearValue() private method

private CheckHebrewYearValue ( int y, int era, String varName ) : void
y int
era int
varName String
return void
        private void CheckHebrewYearValue(int y, int era, String varName) {
            CheckEraRange(era);
            if (y > m_maxHebrewYear || y < m_minHebrewYear) {
                throw new ArgumentOutOfRangeException(
                            varName,
                            String.Format(
                                CultureInfo.CurrentCulture,
                                Environment.GetResourceString("ArgumentOutOfRange_Range"),
                                m_minHebrewYear,
                                m_maxHebrewYear));
            }
        }

Usage Example

Beispiel #1
0
        /// <summary>返回与指定 <see cref="T:System.DateTime" /> 相距指定年数的 <see cref="T:System.DateTime" />。</summary>
        /// <returns>将指定年数添加到指定的 <see cref="T:System.DateTime" /> 中时得到的 <see cref="T:System.DateTime" />。</returns>
        /// <param name="time">
        /// <see cref="T:System.DateTime" />,将向其添加 <paramref name="years" />。</param>
        /// <param name="years">要添加的年数。</param>
        /// <exception cref="T:System.ArgumentException">结果 <see cref="T:System.DateTime" /> 超出了支持的范围。</exception>
        public override DateTime AddYears(DateTime time, int years)
        {
            int datePart = this.GetDatePart(time.Ticks, 0);
            int month    = this.GetDatePart(time.Ticks, 2);
            int day      = this.GetDatePart(time.Ticks, 3);
            int num      = datePart + years;

            HebrewCalendar.CheckHebrewYearValue(num, 0, "years");
            int monthsInYear = this.GetMonthsInYear(num, 0);

            if (month > monthsInYear)
            {
                month = monthsInYear;
            }
            int daysInMonth = this.GetDaysInMonth(num, month);

            if (day > daysInMonth)
            {
                day = daysInMonth;
            }
            long     ticks = this.ToDateTime(num, month, day, 0, 0, 0, 0).Ticks + time.Ticks % 864000000000L;
            DateTime supportedDateTime1 = this.MinSupportedDateTime;
            DateTime supportedDateTime2 = this.MaxSupportedDateTime;

            Calendar.CheckAddResult(ticks, supportedDateTime1, supportedDateTime2);
            return(new DateTime(ticks));
        }
All Usage Examples Of System.Globalization.HebrewCalendar::CheckHebrewYearValue