System.Globalization.TaiwanCalendar.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) {
            return (helper.AddYears(time, years));
        }

Usage Example

        private void VerificationHelper(DateTime value, int addValue)
        {
            System.Globalization.Calendar tc = new TaiwanCalendar();
            DateTime newDate = tc.AddYears(value, addValue);
            _errorNo++;
            Assert.Equal(newDate.Year, (value.Year + addValue));

            if (value.Month == 2)
            {
                if ((DateTime.IsLeapYear(value.Year) && value.Day == 29) || (!DateTime.IsLeapYear(value.Year) && value.Day == 28))
                {
                    if (DateTime.IsLeapYear(newDate.Year))
                    {
                        Assert.Equal(29, newDate.Day);
                    }
                    else
                    {
                        Assert.Equal(28, newDate.Day);
                    }
                }
            }
        }