public void NegTest2() { System.Globalization.Calendar kC = new KoreanCalendar(); DateTime actualValue; Assert.Throws <ArgumentOutOfRangeException>(() => { actualValue = kC.AddMonths(new GregorianCalendar().ToDateTime(9999, 12, 31, 0, 0, 0, 0), 5); }); }
public void PosTest2() { System.Globalization.Calendar kC = new KoreanCalendar(); DateTime maxDT = DateTime.MaxValue; DateTime expectedValue = new GregorianCalendar().ToDateTime(maxDT.Year, maxDT.Month, maxDT.Day, 0, 0, 0, 0); DateTime actualValue; actualValue = kC.AddMonths(expectedValue, -2); Assert.Equal(kC.GetMonth(expectedValue) - 2, kC.GetMonth(actualValue)); }
public void PosTest3() { System.Globalization.Calendar kC = new KoreanCalendar(); DateTime leapDT = new GregorianCalendar().ToDateTime(2003, 1, 29, 0, 0, 0, 0); DateTime expectedValue = leapDT; DateTime actualValue; actualValue = kC.AddMonths(expectedValue, 1); Assert.Equal(kC.GetMonth(expectedValue) + 1, kC.GetMonth(actualValue)); Assert.Equal(kC.GetDayOfMonth(expectedValue) - 1, kC.GetDayOfMonth(actualValue)); }
public void PosTest4() { System.Globalization.Calendar kC = new KoreanCalendar(); DateTime tempDT = new GregorianCalendar().ToDateTime(2006, 7, 31, 0, 0, 0, 0); DateTime expectedValue = tempDT; DateTime actualValue; actualValue = kC.AddMonths(expectedValue, 2); Assert.Equal(kC.GetMonth(expectedValue) + 2, kC.GetMonth(actualValue)); Assert.Equal(kC.GetDayOfMonth(actualValue) + 1, kC.GetDayOfMonth(expectedValue)); }
public static void Main() { // Sets a DateTime to April 3, 2002 of the Gregorian calendar. DateTime myDT = new DateTime(2002, 4, 3, new GregorianCalendar()); // Creates an instance of the KoreanCalendar. KoreanCalendar myCal = new KoreanCalendar(); // Displays the values of the DateTime. Console.WriteLine("April 3, 2002 of the Gregorian calendar equals the following in the Korean calendar:"); DisplayValues(myCal, myDT); // Adds two years and ten months. myDT = myCal.AddYears(myDT, 2); myDT = myCal.AddMonths(myDT, 10); // Displays the values of the DateTime. Console.WriteLine("After adding two years and ten months:"); DisplayValues(myCal, myDT); }