System.Globalization.CCGregorianCalendar.AddYears C# (CSharp) Метод

AddYears() публичный статический Метод

Adds years to the given date.
public static AddYears ( System time, int years ) : System.DateTime
time System The /// to which to add /// months. ///
years int The number of years to add.
Результат System.DateTime
	public static System.DateTime AddYears(System.DateTime time,
		int years)
	{
		int rd = CCFixed.FromDateTime(time);
		int day, month, year;
		dmy_from_fixed(out day, out month, out year, rd);
		year += years;
		int maxday = GetDaysInMonth (year, month);
		if (day > maxday)
			day = maxday;
		rd = fixed_from_dmy(day, month, year);
		System.DateTime t = CCFixed.ToDateTime(rd);
		return t.Add(time.TimeOfDay);
	}

Usage Example

Пример #1
0
        /// <summary>Returns a <see cref="T:System.DateTime" /> that is the specified number of years away from the specified <see cref="T:System.DateTime" />.</summary>
        /// <returns>The <see cref="T:System.DateTime" /> that results from adding the specified number of years to the specified <see cref="T:System.DateTime" />.</returns>
        /// <param name="time">The <see cref="T:System.DateTime" /> to which to add years. </param>
        /// <param name="years">The number of years to add. </param>
        /// <exception cref="T:System.ArgumentException">The resulting <see cref="T:System.DateTime" /> is outside the supported range. </exception>
        public override DateTime AddYears(DateTime time, int years)
        {
            DateTime dateTime = CCGregorianCalendar.AddYears(time, years);

            this.M_CheckDateTime(dateTime);
            return(dateTime);
        }
All Usage Examples Of System.Globalization.CCGregorianCalendar::AddYears