System.Globalization.EastAsianLunisolarCalendar.AddYears C# (CSharp) Method

AddYears() public method

public AddYears ( System.DateTime time, int years ) : System.DateTime
time System.DateTime
years int
return System.DateTime
        public override DateTime AddYears(DateTime time, int years) {
            CheckTicksRange(time.Ticks);

            int y=0;  int m=0; int d=0;
            TimeToLunar(time, ref y, ref m, ref d);

            y += years;

            if (m==13 && !InternalIsLeapYear(y)) {
                m = 12;
                d = InternalGetDaysInMonth(y, m);
            }
            int DaysInMonths = InternalGetDaysInMonth(y, m);
            if (d > DaysInMonths) {
                d = DaysInMonths;
            }

            DateTime dt = LunarToTime(time, y, m, d);
            CheckAddResult(dt.Ticks, MinSupportedDateTime, MaxSupportedDateTime);
            return (dt);
        }