< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 250
Coverable lines: 250
Total lines: 686
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 146
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Private.CoreLib/src/System/Globalization/EastAsianLunisolarCalendar.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4namespace System.Globalization
 5{
 6    public abstract class EastAsianLunisolarCalendar : Calendar
 7    {
 8        private const int LeapMonth = 0;
 9        private const int Jan1Month = 1;
 10        private const int Jan1Date = 2;
 11        private const int nDaysPerMonth = 3;
 12
 13        // # of days so far in the solar year
 014        private static ReadOnlySpan<int> DaysToMonth365 => [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
 015        private static ReadOnlySpan<int> DaysToMonth366 => [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335];
 16
 017        public override CalendarAlgorithmType AlgorithmType => CalendarAlgorithmType.LunisolarCalendar;
 18
 19        /// <summary>
 20        /// Return the year number in the 60-year cycle.
 21        /// </summary>
 22        public virtual int GetSexagenaryYear(DateTime time)
 23        {
 024            CheckTicksRange(time.Ticks);
 25
 026            TimeToLunar(time, out int year, out _, out _);
 027            return ((year - 4) % 60) + 1;
 28        }
 29
 30        /// <summary>
 31        /// Return the celestial year from the 60-year cycle.
 32        /// The returned value is from 1 ~ 10.
 33        /// </summary>
 34        public int GetCelestialStem(int sexagenaryYear)
 35        {
 036            if (sexagenaryYear < 1 || sexagenaryYear > 60)
 37            {
 038                throw new ArgumentOutOfRangeException(
 039                    nameof(sexagenaryYear),
 040                    sexagenaryYear,
 041                    SR.Format(SR.ArgumentOutOfRange_Range, 1, 60));
 42            }
 43
 044            return ((sexagenaryYear - 1) % 10) + 1;
 45        }
 46
 47        /// <summary>
 48        /// Return the Terrestial Branch from the 60-year cycle.
 49        /// The returned value is from 1 ~ 12.
 50        /// </summary>
 51        public int GetTerrestrialBranch(int sexagenaryYear)
 52        {
 053            if (sexagenaryYear < 1 || sexagenaryYear > 60)
 54            {
 055                throw new ArgumentOutOfRangeException(
 056                    nameof(sexagenaryYear),
 057                    sexagenaryYear,
 058                    SR.Format(SR.ArgumentOutOfRange_Range, 1, 60));
 59            }
 60
 061            return ((sexagenaryYear - 1) % 12) + 1;
 62        }
 63
 64        internal abstract int GetYearInfo(int LunarYear, int Index);
 65        internal abstract int GetYear(int year, DateTime time);
 66        internal abstract int GetGregorianYear(int year, int era);
 67
 68        internal abstract int MinCalendarYear { get; }
 69        internal abstract int MaxCalendarYear { get; }
 70        internal abstract EraInfo[]? CalEraInfo { get; }
 71        internal abstract DateTime MinDate { get; }
 72        internal abstract DateTime MaxDate { get; }
 73
 74        internal const int MaxCalendarMonth = 13;
 75        internal const int MaxCalendarDay = 30;
 76
 77        internal int MinEraCalendarYear(int era)
 78        {
 079            EraInfo[]? eraInfo = CalEraInfo;
 080            if (eraInfo == null)
 81            {
 082                return MinCalendarYear;
 83            }
 84
 085            if (era == CurrentEra)
 86            {
 087                era = CurrentEraValue;
 88            }
 89
 90            // Era has to be in the supported range otherwise we will throw exception in CheckEraRange()
 091            if (era == GetEra(MinDate))
 92            {
 093                return GetYear(MinCalendarYear, MinDate);
 94            }
 95
 096            for (int i = 0; i < eraInfo.Length; i++)
 97            {
 098                if (era == eraInfo[i].era)
 99                {
 0100                    return eraInfo[i].minEraYear;
 101                }
 102            }
 103
 0104            throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
 105        }
 106
 107        internal int MaxEraCalendarYear(int era)
 108        {
 0109            EraInfo[]? eraInfo = CalEraInfo;
 0110            if (eraInfo == null)
 111            {
 0112                return MaxCalendarYear;
 113            }
 114
 0115            if (era == CurrentEra)
 116            {
 0117                era = CurrentEraValue;
 118            }
 119
 120            // Era has to be in the supported range otherwise we will throw exception in CheckEraRange()
 0121            if (era == GetEra(MaxDate))
 122            {
 0123                return GetYear(MaxCalendarYear, MaxDate);
 124            }
 125
 0126            for (int i = 0; i < eraInfo.Length; i++)
 127            {
 0128                if (era == eraInfo[i].era)
 129                {
 0130                    return eraInfo[i].maxEraYear;
 131                }
 132            }
 133
 0134            throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
 135        }
 136
 0137        internal EastAsianLunisolarCalendar()
 138        {
 0139        }
 140
 141        internal void CheckTicksRange(long ticks)
 142        {
 0143            if (ticks < MinSupportedDateTime.Ticks || ticks > MaxSupportedDateTime.Ticks)
 144            {
 0145                throw new ArgumentOutOfRangeException(
 0146                                "time",
 0147                                ticks,
 0148                                SR.Format(CultureInfo.InvariantCulture, SR.ArgumentOutOfRange_CalendarRange,
 0149                                MinSupportedDateTime, MaxSupportedDateTime));
 150            }
 0151        }
 152
 153        internal void CheckEraRange(int era)
 154        {
 0155            if (era == CurrentEra)
 156            {
 0157                era = CurrentEraValue;
 158            }
 159
 0160            if (era < GetEra(MinDate) || era > GetEra(MaxDate))
 161            {
 0162                throw new ArgumentOutOfRangeException(nameof(era), era, SR.ArgumentOutOfRange_InvalidEraValue);
 163            }
 0164        }
 165
 166        internal int CheckYearRange(int year, int era)
 167        {
 0168            CheckEraRange(era);
 0169            year = GetGregorianYear(year, era);
 170
 0171            if (year < MinCalendarYear || year > MaxCalendarYear)
 172            {
 0173                throw new ArgumentOutOfRangeException(
 0174                    nameof(year),
 0175                    year,
 0176                    SR.Format(SR.ArgumentOutOfRange_Range, MinEraCalendarYear(era), MaxEraCalendarYear(era)));
 177            }
 0178            return year;
 179        }
 180
 181        internal int CheckYearMonthRange(int year, int month, int era)
 182        {
 0183            year = CheckYearRange(year, era);
 184
 0185            if (month == 13)
 186            {
 187                // Reject if there is no leap month this year
 0188                if (GetYearInfo(year, LeapMonth) == 0)
 189                {
 0190                    ThrowHelper.ThrowArgumentOutOfRange_Month(month);
 191                }
 192            }
 193
 0194            if (month < 1 || month > 13)
 195            {
 0196                ThrowHelper.ThrowArgumentOutOfRange_Month(month);
 197            }
 198
 0199            return year;
 200        }
 201
 202        internal int InternalGetDaysInMonth(int year, int month)
 203        {
 0204            int mask = 0x8000;
 205
 206            // convert the lunar day into a lunar month/date
 0207            mask >>= (month - 1);
 0208            if ((GetYearInfo(year, nDaysPerMonth) & mask) == 0)
 209            {
 0210                return 29;
 211            }
 212
 0213            return 30;
 214        }
 215
 216        /// <summary>
 217        /// Returns the number of days in the month given by the year and
 218        /// month arguments.
 219        /// </summary>
 220        public override int GetDaysInMonth(int year, int month, int era)
 221        {
 0222            year = CheckYearMonthRange(year, month, era);
 0223            return InternalGetDaysInMonth(year, month);
 224        }
 225
 226        private static bool GregorianIsLeapYear(int y)
 227        {
 0228            if ((y % 4) != 0)
 229            {
 0230                return false;
 231            }
 0232            if ((y % 100) != 0)
 233            {
 0234                return true;
 235            }
 236
 0237            return (y % 400) == 0;
 238        }
 239
 240        /// <summary>
 241        /// Returns the date and time converted to a DateTime value.
 242        /// Throws an exception if the n-tuple is invalid.
 243        /// </summary>
 244        public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisec
 245        {
 0246            year = CheckYearMonthRange(year, month, era);
 0247            int daysInMonth = InternalGetDaysInMonth(year, month);
 0248            if (day < 1 || day > daysInMonth)
 249            {
 0250                throw new ArgumentOutOfRangeException(
 0251                    nameof(day),
 0252                    day,
 0253                    SR.Format(SR.ArgumentOutOfRange_Day, daysInMonth, month));
 254            }
 255
 0256            if (!LunarToGregorian(year, month, day, out int gy, out int gm, out int gd))
 257            {
 0258                throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_BadYearMonthDay);
 259            }
 260
 0261            return new DateTime(gy, gm, gd, hour, minute, second, millisecond);
 262        }
 263
 264        /// <summary>
 265        /// Calculates lunar calendar info for the given gregorian year, month, date.
 266        /// The input date should be validated before calling this method.
 267        /// </summary>
 268        private void GregorianToLunar(int solarYear, int solarMonth, int solarDate, out int lunarYear, out int lunarMont
 269        {
 0270            bool isLeapYear = GregorianIsLeapYear(solarYear);
 271            int jan1Month;
 272            int jan1Date;
 273
 274            // Calculate the day number in the solar year.
 0275            int solarDay = isLeapYear ? DaysToMonth366[solarMonth - 1] : DaysToMonth365[solarMonth - 1];
 0276            solarDay += solarDate;
 277
 278            // Calculate the day number in the lunar year.
 0279            int lunarDay = solarDay;
 0280            lunarYear = solarYear;
 0281            if (lunarYear == (MaxCalendarYear + 1))
 282            {
 0283                lunarYear--;
 0284                lunarDay += (GregorianIsLeapYear(lunarYear) ? 366 : 365);
 0285                jan1Month = GetYearInfo(lunarYear, Jan1Month);
 0286                jan1Date = GetYearInfo(lunarYear, Jan1Date);
 287            }
 288            else
 289            {
 0290                jan1Month = GetYearInfo(lunarYear, Jan1Month);
 0291                jan1Date = GetYearInfo(lunarYear, Jan1Date);
 292
 293                // check if this solar date is actually part of the previous
 294                // lunar year
 0295                if ((solarMonth < jan1Month) ||
 0296                    (solarMonth == jan1Month && solarDate < jan1Date))
 297                {
 298                    // the corresponding lunar day is actually part of the previous
 299                    // lunar year
 0300                    lunarYear--;
 301
 302                    // add a solar year to the lunar day #
 0303                    lunarDay += (GregorianIsLeapYear(lunarYear) ? 366 : 365);
 304
 305                    // update the new start of year
 0306                    jan1Month = GetYearInfo(lunarYear, Jan1Month);
 0307                    jan1Date = GetYearInfo(lunarYear, Jan1Date);
 308                }
 309            }
 310
 311            // convert solar day into lunar day.
 312            // subtract off the beginning part of the solar year which is not
 313            // part of the lunar year.  since this part is always in Jan or Feb,
 314            // we don't need to handle Leap Year (LY only affects March
 315            // and later).
 0316            lunarDay -= DaysToMonth365[jan1Month - 1];
 0317            lunarDay -= (jan1Date - 1);
 318
 319            // convert the lunar day into a lunar month/date
 0320            int mask = 0x8000;
 0321            int yearInfo = GetYearInfo(lunarYear, nDaysPerMonth);
 0322            int days = ((yearInfo & mask) != 0) ? 30 : 29;
 0323            lunarMonth = 1;
 0324            while (lunarDay > days)
 325            {
 0326                lunarDay -= days;
 0327                lunarMonth++;
 0328                mask >>= 1;
 0329                days = ((yearInfo & mask) != 0) ? 30 : 29;
 330            }
 0331            lunarDate = lunarDay;
 0332        }
 333
 334        /// <summary>
 335        /// Convert from Lunar to Gregorian
 336        /// </summary>
 337        /// <remarks>
 338        /// Highly inefficient, but it works based on the forward conversion
 339        /// </remarks>
 340        private bool LunarToGregorian(int lunarYear, int lunarMonth, int lunarDate, out int solarYear, out int solarMont
 341        {
 0342            if (lunarDate < 1 || lunarDate > 30)
 343            {
 0344                solarYear = 0;
 0345                solarMonth = 0;
 0346                solarDay = 0;
 0347                return false;
 348            }
 349
 0350            int numLunarDays = lunarDate - 1;
 351
 352            // Add previous months days to form the total num of days from the first of the month.
 0353            for (int i = 1; i < lunarMonth; i++)
 354            {
 0355                numLunarDays += InternalGetDaysInMonth(lunarYear, i);
 356            }
 357
 358            // Get Gregorian First of year
 0359            int jan1Month = GetYearInfo(lunarYear, Jan1Month);
 0360            int jan1Date = GetYearInfo(lunarYear, Jan1Date);
 361
 362            // calc the solar day of year of 1 Lunar day
 0363            bool isLeapYear = GregorianIsLeapYear(lunarYear);
 0364            ReadOnlySpan<int> days = isLeapYear ? DaysToMonth366 : DaysToMonth365;
 365
 0366            solarDay = jan1Date;
 367
 0368            if (jan1Month > 1)
 369            {
 0370                solarDay += days[jan1Month - 1];
 371            }
 372
 373            // Add the actual lunar day to get the solar day we want
 0374            solarDay += numLunarDays;
 375
 0376            if (solarDay > (365 + (isLeapYear ? 1 : 0)))
 377            {
 0378                solarYear = lunarYear + 1;
 0379                solarDay -= (365 + (isLeapYear ? 1 : 0));
 380            }
 381            else
 382            {
 0383                solarYear = lunarYear;
 384            }
 385
 0386            for (solarMonth = 1; solarMonth < 12; solarMonth++)
 387            {
 0388                if (days[solarMonth] >= solarDay)
 389                {
 390                    break;
 391                }
 392            }
 393
 0394            solarDay -= days[solarMonth - 1];
 0395            return true;
 396        }
 397
 398        private DateTime LunarToTime(DateTime time, int year, int month, int day)
 399        {
 0400            LunarToGregorian(year, month, day, out int gy, out int gm, out int gd);
 0401            time.GetTime(out int hour, out int minute, out int second, out int millisecond);
 0402            return GregorianCalendar.GetDefaultInstance().ToDateTime(gy, gm, gd, hour, minute, second, millisecond);
 403        }
 404
 405        private void TimeToLunar(DateTime time, out int year, out int month, out int day)
 406        {
 0407            Calendar gregorianCalendar = GregorianCalendar.GetDefaultInstance();
 0408            int gy = gregorianCalendar.GetYear(time);
 0409            int gm = gregorianCalendar.GetMonth(time);
 0410            int gd = gregorianCalendar.GetDayOfMonth(time);
 411
 0412            GregorianToLunar(gy, gm, gd, out year, out month, out day);
 0413        }
 414
 415        /// <summary>
 416        /// Returns the DateTime resulting from adding the given number of
 417        /// months to the specified DateTime. The result is computed by incrementing
 418        /// (or decrementing) the year and month parts of the specified DateTime by
 419        /// value months, and, if required, adjusting the day part of the
 420        /// resulting date downwards to the last day of the resulting month in the
 421        /// resulting year. The time-of-day part of the result is the same as the
 422        /// time-of-day part of the specified DateTime.
 423        /// </summary>
 424        public override DateTime AddMonths(DateTime time, int months)
 425        {
 0426            if (months < -120000 || months > 120000)
 427            {
 0428                throw new ArgumentOutOfRangeException(
 0429                    nameof(months),
 0430                    months,
 0431                    SR.Format(SR.ArgumentOutOfRange_Range, -120000, 120000));
 432            }
 433
 0434            CheckTicksRange(time.Ticks);
 0435            TimeToLunar(time, out int y, out int m, out int d);
 436
 0437            int i = m + months;
 0438            if (i > 0)
 439            {
 0440                int monthsInYear = InternalIsLeapYear(y) ? 13 : 12;
 441
 0442                while (i - monthsInYear > 0)
 443                {
 0444                    i -= monthsInYear;
 0445                    y++;
 0446                    monthsInYear = InternalIsLeapYear(y) ? 13 : 12;
 447                }
 0448                m = i;
 449            }
 450            else
 451            {
 452                int monthsInYear;
 0453                while (i <= 0)
 454                {
 0455                    monthsInYear = InternalIsLeapYear(y - 1) ? 13 : 12;
 0456                    i += monthsInYear;
 0457                    y--;
 458                }
 0459                m = i;
 460            }
 461
 0462            int days = InternalGetDaysInMonth(y, m);
 0463            if (d > days)
 464            {
 0465                d = days;
 466            }
 0467            DateTime dt = LunarToTime(time, y, m, d);
 468
 0469            CheckAddResult(dt.Ticks, MinSupportedDateTime, MaxSupportedDateTime);
 0470            return dt;
 471        }
 472
 473        public override DateTime AddYears(DateTime time, int years)
 474        {
 0475            CheckTicksRange(time.Ticks);
 0476            TimeToLunar(time, out int y, out int m, out int d);
 477
 0478            y += years;
 479
 0480            if (m == 13 && !InternalIsLeapYear(y))
 481            {
 0482                m = 12;
 0483                d = InternalGetDaysInMonth(y, m);
 484            }
 0485            int daysInMonths = InternalGetDaysInMonth(y, m);
 0486            if (d > daysInMonths)
 487            {
 0488                d = daysInMonths;
 489            }
 490
 0491            DateTime dt = LunarToTime(time, y, m, d);
 0492            CheckAddResult(dt.Ticks, MinSupportedDateTime, MaxSupportedDateTime);
 0493            return dt;
 494        }
 495
 496        /// <summary>
 497        /// Returns the day-of-year part of the specified DateTime. The returned value
 498        /// is an integer between 1 and [354|355 |383|384].
 499        /// </summary>
 500        public override int GetDayOfYear(DateTime time)
 501        {
 0502            CheckTicksRange(time.Ticks);
 0503            TimeToLunar(time, out int y, out int m, out int d);
 504
 0505            for (int i = 1; i < m; i++)
 506            {
 0507                d += InternalGetDaysInMonth(y, i);
 508            }
 0509            return d;
 510        }
 511
 512        /// <summary>
 513        /// Returns the day-of-month part of the specified DateTime. The returned
 514        /// value is an integer between 1 and 29 or 30.
 515        /// </summary>
 516        public override int GetDayOfMonth(DateTime time)
 517        {
 0518            CheckTicksRange(time.Ticks);
 519
 0520            TimeToLunar(time, out _, out _, out int d);
 521
 0522            return d;
 523        }
 524
 525        /// <summary>
 526        /// Returns the number of days in the year given by the year argument for the current era.
 527        /// </summary>
 528        public override int GetDaysInYear(int year, int era)
 529        {
 0530            year = CheckYearRange(year, era);
 531
 0532            int days = 0;
 0533            int monthsInYear = InternalIsLeapYear(year) ? 13 : 12;
 534
 0535            while (monthsInYear != 0)
 536            {
 0537                days += InternalGetDaysInMonth(year, monthsInYear--);
 538            }
 539
 0540            return days;
 541        }
 542
 543        /// <summary>
 544        /// Returns the month part of the specified DateTime.
 545        /// The returned value is an integer between 1 and 13.
 546        /// </summary>
 547        public override int GetMonth(DateTime time)
 548        {
 0549            CheckTicksRange(time.Ticks);
 550
 0551            TimeToLunar(time, out _, out int m, out _);
 552
 0553            return m;
 554        }
 555
 556        /// <summary>
 557        /// Returns the year part of the specified DateTime.
 558        /// The returned value is an integer between 1 and MaxCalendarYear.
 559        /// </summary>
 560        public override int GetYear(DateTime time)
 561        {
 0562            CheckTicksRange(time.Ticks);
 563
 0564            TimeToLunar(time, out int y, out _, out _);
 565
 0566            return GetYear(y, time);
 567        }
 568
 569        /// <summary>
 570        /// Returns the day-of-week part of the specified DateTime. The returned value
 571        /// is an integer between 0 and 6, where 0 indicates Sunday, 1 indicates
 572        /// Monday, 2 indicates Tuesday, 3 indicates Wednesday, 4 indicates
 573        /// Thursday, 5 indicates Friday, and 6 indicates Saturday.
 574        /// </summary>
 575        public override DayOfWeek GetDayOfWeek(DateTime time)
 576        {
 0577            CheckTicksRange(time.Ticks);
 0578            return time.DayOfWeek;
 579        }
 580
 581        /// <summary>
 582        /// Returns the number of months in the specified year and era.
 583        /// </summary>
 584        public override int GetMonthsInYear(int year, int era)
 585        {
 0586            year = CheckYearRange(year, era);
 0587            return InternalIsLeapYear(year) ? 13 : 12;
 588        }
 589
 590        /// <summary>
 591        /// Checks whether a given day in the specified era is a leap day.
 592        /// This method returns true if the date is a leap day, or false if not.
 593        /// </summary>
 594        public override bool IsLeapDay(int year, int month, int day, int era)
 595        {
 0596            year = CheckYearMonthRange(year, month, era);
 0597            int daysInMonth = InternalGetDaysInMonth(year, month);
 598
 0599            if (day < 1 || day > daysInMonth)
 600            {
 0601                throw new ArgumentOutOfRangeException(
 0602                    nameof(day),
 0603                    day,
 0604                    SR.Format(SR.ArgumentOutOfRange_Day, daysInMonth, month));
 605            }
 606
 0607            int m = GetYearInfo(year, LeapMonth);
 0608            return (m != 0) && (month == (m + 1));
 609        }
 610
 611        /// <summary>
 612        /// Checks whether a given month in the specified era is a leap month.
 613        /// This method returns true if month is a leap month, or false if not.
 614        /// </summary>
 615        public override bool IsLeapMonth(int year, int month, int era)
 616        {
 0617            year = CheckYearMonthRange(year, month, era);
 0618            int m = GetYearInfo(year, LeapMonth);
 0619            return (m != 0) && (month == (m + 1));
 620        }
 621
 622        /// <summary>
 623        /// Returns  the leap month in a calendar year of the specified era. This method returns 0
 624        /// if this year is not a leap year.
 625        /// </summary>
 626        public override int GetLeapMonth(int year, int era)
 627        {
 0628            year = CheckYearRange(year, era);
 0629            int month = GetYearInfo(year, LeapMonth);
 0630            return month > 0 ? month + 1 : 0;
 631        }
 632
 633        internal bool InternalIsLeapYear(int year)
 634        {
 0635            return GetYearInfo(year, LeapMonth) != 0;
 636        }
 637
 638        /// <summary>
 639        /// Checks whether a given year in the specified era is a leap year.
 640        /// This method returns true if year is a leap year, or false if not.
 641        /// </summary>
 642        public override bool IsLeapYear(int year, int era)
 643        {
 0644            year = CheckYearRange(year, era);
 0645            return InternalIsLeapYear(year);
 646        }
 647
 648        private const int DefaultGregorianTwoDigitYearMax = 2049;
 649
 650        public override int TwoDigitYearMax
 651        {
 652            get
 653            {
 0654                if (_twoDigitYearMax == -1)
 655                {
 0656                    _twoDigitYearMax = GetSystemTwoDigitYearSetting(BaseCalendarID, GetYear(new DateTime(DefaultGregoria
 657                }
 658
 0659                return _twoDigitYearMax;
 660            }
 661            set
 662            {
 0663                VerifyWritable();
 0664                if (value < 99 || value > MaxCalendarYear)
 665                {
 0666                    throw new ArgumentOutOfRangeException(
 0667                        nameof(value),
 0668                        value,
 0669                        SR.Format(SR.ArgumentOutOfRange_Range, 99, MaxCalendarYear));
 670                }
 671
 0672                _twoDigitYearMax = value;
 0673            }
 674        }
 675
 676        public override int ToFourDigitYear(int year)
 677        {
 0678            ArgumentOutOfRangeException.ThrowIfNegative(year);
 679
 0680            year = base.ToFourDigitYear(year);
 0681            CheckYearRange(year, CurrentEra);
 0682            return year;
 683        }
 684    }
 685}
 686

Methods/Properties

DaysToMonth365()
DaysToMonth366()
AlgorithmType()
GetSexagenaryYear(System.DateTime)
GetCelestialStem(System.Int32)
GetTerrestrialBranch(System.Int32)
MinEraCalendarYear(System.Int32)
MaxEraCalendarYear(System.Int32)
.ctor()
CheckTicksRange(System.Int64)
CheckEraRange(System.Int32)
CheckYearRange(System.Int32,System.Int32)
CheckYearMonthRange(System.Int32,System.Int32,System.Int32)
InternalGetDaysInMonth(System.Int32,System.Int32)
GetDaysInMonth(System.Int32,System.Int32,System.Int32)
GregorianIsLeapYear(System.Int32)
ToDateTime(System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32)
GregorianToLunar(System.Int32,System.Int32,System.Int32,System.Int32&,System.Int32&,System.Int32&)
LunarToGregorian(System.Int32,System.Int32,System.Int32,System.Int32&,System.Int32&,System.Int32&)
LunarToTime(System.DateTime,System.Int32,System.Int32,System.Int32)
TimeToLunar(System.DateTime,System.Int32&,System.Int32&,System.Int32&)
AddMonths(System.DateTime,System.Int32)
AddYears(System.DateTime,System.Int32)
GetDayOfYear(System.DateTime)
GetDayOfMonth(System.DateTime)
GetDaysInYear(System.Int32,System.Int32)
GetMonth(System.DateTime)
GetYear(System.DateTime)
GetDayOfWeek(System.DateTime)
GetMonthsInYear(System.Int32,System.Int32)
IsLeapDay(System.Int32,System.Int32,System.Int32,System.Int32)
IsLeapMonth(System.Int32,System.Int32,System.Int32)
GetLeapMonth(System.Int32,System.Int32)
InternalIsLeapYear(System.Int32)
IsLeapYear(System.Int32,System.Int32)
TwoDigitYearMax()
TwoDigitYearMax(System.Int32)
ToFourDigitYear(System.Int32)