CheckTicksRange() private méthode

private CheckTicksRange ( long ticks ) : void
ticks long
Résultat void
Exemple #1
0
        internal virtual int GetDatePart(long ticks, int part)
        {
            HebrewCalendar.CheckTicksRange(ticks);
            DateTime dateTime = new DateTime(ticks);
            int      year     = dateTime.Year;
            int      month    = dateTime.Month;
            int      day      = dateTime.Day;

            HebrewCalendar.__DateBuffer lunarDate = new HebrewCalendar.__DateBuffer();
            lunarDate.year = year + 3760;
            int index1 = HebrewCalendar.GetLunarMonthDay(year, lunarDate);

            HebrewCalendar.__DateBuffer result = new HebrewCalendar.__DateBuffer();
            result.year  = lunarDate.year;
            result.month = lunarDate.month;
            result.day   = lunarDate.day;
            long absoluteDate = GregorianCalendar.GetAbsoluteDate(year, month, day);

            if (month == 1 && day == 1)
            {
                return(HebrewCalendar.GetResult(result, part));
            }
            long num1 = absoluteDate - GregorianCalendar.GetAbsoluteDate(year, 1, 1);

            if (num1 + (long)lunarDate.day <= (long)HebrewCalendar.LunarMonthLen[index1, lunarDate.month])
            {
                result.day += (int)num1;
                return(HebrewCalendar.GetResult(result, part));
            }
            ++result.month;
            result.day = 1;
            long num2 = num1 - (long)(HebrewCalendar.LunarMonthLen[index1, lunarDate.month] - lunarDate.day);

            if (num2 > 1L)
            {
                while (num2 > (long)HebrewCalendar.LunarMonthLen[index1, result.month])
                {
                    long num3 = num2;
                    int[,] numArray = HebrewCalendar.LunarMonthLen;
                    int index2 = index1;
                    HebrewCalendar.__DateBuffer dateBuffer = result;
                    int num4 = dateBuffer.month;
                    int num5 = num4 + 1;
                    dateBuffer.month = num5;
                    int  index3 = num4;
                    long num6   = (long)numArray[index2, index3];
                    num2 = num3 - num6;
                    if (result.month > 13 || HebrewCalendar.LunarMonthLen[index1, result.month] == 0)
                    {
                        ++result.year;
                        index1       = HebrewCalendar.HebrewTable[(year + 1 - 1583) * 2 + 1];
                        result.month = 1;
                    }
                }
                result.day += (int)(num2 - 1L);
            }
            return(HebrewCalendar.GetResult(result, part));
        }
Exemple #2
0
        /// <summary>返回一个 <see cref="T:System.DateTime" />,它设置为指定纪元中的指定日期和时间。</summary>
        /// <returns>设置为当前纪元中的指定日期和时间的 <see cref="T:System.DateTime" />。</returns>
        /// <param name="year">表示年份的整数。</param>
        /// <param name="month">1 到 13 之间的一个整数,它表示月份。</param>
        /// <param name="day">1 到 30 之间的一个整数,它表示天。</param>
        /// <param name="hour">0 与 23 之间的一个整数,它表示小时。</param>
        /// <param name="minute">0 与 59 之间的一个整数,它表示分钟。</param>
        /// <param name="second">0 与 59 之间的一个整数,它表示秒。</param>
        /// <param name="millisecond">0 与 999 之间的一个整数,它表示毫秒。</param>
        /// <param name="era">表示纪元的整数。指定 <see cref="F:System.Globalization.HebrewCalendar.HebrewEra" /> 或 HebrewCalendar.Eras[Calendar.CurrentEra]。</param>
        /// <exception cref="T:System.ArgumentOutOfRangeException">
        /// <paramref name="year" />、<paramref name="month" />、<paramref name="day" /> 或 <paramref name="era" /> 超出了当前 <see cref="T:System.Globalization.HebrewCalendar" /> 对象支持的范围。- 或 -<paramref name="hour" /> 小于 0 或大于 23。- 或 -<paramref name="minute" /> 小于 0 或大于 59。- 或 -<paramref name="second" /> 小于 0 或大于 59。- 或 -<paramref name="millisecond" /> 小于 0 或大于 999。</exception>
        public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era)
        {
            HebrewCalendar.CheckHebrewYearValue(year, era, "year");
            this.CheckHebrewMonthValue(year, month, era);
            this.CheckHebrewDayValue(year, month, day, era);
            DateTime gregorian = HebrewCalendar.HebrewToGregorian(year, month, day, hour, minute, second, millisecond);

            HebrewCalendar.CheckTicksRange(gregorian.Ticks);
            return(gregorian);
        }