public AddYears ( System.DateTime time, int years ) : System.DateTime | ||
time | System.DateTime | |
years | int | |
리턴 | System.DateTime |
public void PosTest5() { DateTime initialTime; int years; DateTime resultingTime; System.Globalization.Calendar myCalendar = new GregorianCalendar(GregorianCalendarTypes.USEnglish); years = 13; initialTime = myCalendar.ToDateTime(2000, 2, 29, 10, 30, 24, 0); resultingTime = myCalendar.AddYears(initialTime, years); VerifyAddyearsResult(myCalendar, initialTime, resultingTime, years); }
public void PosTest3() { DateTime initialTime; int years; DateTime resultingTime; System.Globalization.Calendar myCalendar = new GregorianCalendar(GregorianCalendarTypes.USEnglish); years = -99; initialTime = myCalendar.MaxSupportedDateTime; resultingTime = myCalendar.AddYears(initialTime, years); VerifyAddyearsResult(myCalendar, initialTime, resultingTime, years); }
public void PosTest1() { DateTime initialTime; int years; DateTime resultingTime; System.Globalization.Calendar myCalendar = new GregorianCalendar(GregorianCalendarTypes.USEnglish); years = 0; initialTime = DateTime.Now; resultingTime = myCalendar.AddYears(initialTime, years); Assert.Equal(initialTime, resultingTime); }
/// <summary> /// Inherited code: Requires comment. /// </summary> /// <param name="time">Inherited code: Requires comment 1.</param> /// <param name="years">Inherited code: Requires comment 2.</param> /// <returns>Inherited code: Requires comment 3.</returns> public static DateTime? AddYears(DateTime time, int years) { System.Globalization.Calendar cal = new GregorianCalendar(); try { return cal.AddYears(time, years); } catch (ArgumentException) { return null; } }
public void PosTest4() { DateTime initialTime; int years; DateTime resultingTime; System.Globalization.Calendar myCalendar = new GregorianCalendar(GregorianCalendarTypes.USEnglish); years = 1; long maxTimeInTicks = myCalendar.MaxSupportedDateTime.Ticks; long minTimeInTikcs = myCalendar.MinSupportedDateTime.Ticks; initialTime = new DateTime(_generator.GetInt64(-55) % maxTimeInTicks); resultingTime = myCalendar.AddYears(initialTime, years); VerifyAddyearsResult(myCalendar, initialTime, resultingTime, years); }
public void AddYearOnLeapYear () { GregorianCalendar c = new GregorianCalendar (); DateTime d = new DateTime (2004, 2, 29); DateTime prev = c.AddYears (d, -1); Assert.AreEqual (2, prev.Month, "prev"); DateTime next = c.AddYears (d, 1); Assert.AreEqual (2, next.Month, "next"); }
public void NegTest1() { DateTime time; int years; System.Globalization.Calendar myCalendar; time = DateTime.Now; years = 9999; myCalendar = new GregorianCalendar(GregorianCalendarTypes.USEnglish); Assert.Throws<ArgumentOutOfRangeException>(() => { myCalendar.AddYears(time, years); }); }
private void ProcessPageUpKey() { System.Globalization.Calendar _cal = new GregorianCalendar(); if (this.DisplayMode == CalendarMode.Month) { DateTime selectedDate = _cal.AddMonths(this.SelectedDate.GetValueOrDefault(DateTime.Today), -1); if (IsValidDate(this,selectedDate)) { OnDayClick(selectedDate); } } else { Debug.Assert(this.DisplayMode == CalendarMode.Year); DateTime selectedMonth = _cal.AddYears(this._selectedMonth, -1); OnSelectedMonthChanged(selectedMonth); } }