本文整理汇总了C#中System.Globalization.GregorianCalendar.AddMonths方法的典型用法代码示例。如果您正苦于以下问题:C# GregorianCalendar.AddMonths方法的具体用法?C# GregorianCalendar.AddMonths怎么用?C# GregorianCalendar.AddMonths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Globalization.GregorianCalendar
的用法示例。
在下文中一共展示了GregorianCalendar.AddMonths方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PosTest3
public void PosTest3()
{
DateTime initialTime;
int months;
DateTime resultingTime;
System.Globalization.Calendar myCalendar = new GregorianCalendar(GregorianCalendarTypes.USEnglish);
months = -1 * _generator.GetInt32(-55) % c_MAX_MONTHS_NUMBER - 1;
initialTime = myCalendar.MaxSupportedDateTime;
resultingTime = myCalendar.AddMonths(initialTime, months);
VerifyAddMonthsResult(myCalendar, initialTime, resultingTime, months);
}
示例2: AddMonths
/// <summary>
/// Inherited code: Requires comment.
/// </summary>
/// <param name="time">Inherited code: Requires comment 1.</param>
/// <param name="months">Inherited code: Requires comment 2.</param>
/// <returns>Inherited code: Requires comment 3.</returns>
public static DateTime? AddMonths(DateTime time, int months)
{
System.Globalization.Calendar cal = new GregorianCalendar();
try
{
return cal.AddMonths(time, months);
}
catch (ArgumentException)
{
return null;
}
}
示例3: PosTest1
public void PosTest1()
{
DateTime initialTime;
int months;
DateTime resultingTime;
System.Globalization.Calendar myCalendar = new GregorianCalendar(GregorianCalendarTypes.USEnglish);
months = 0;
initialTime = DateTime.Now;
resultingTime = myCalendar.AddMonths(initialTime, months);
Assert.Equal(initialTime, resultingTime);
}
示例4: PosTest4
public void PosTest4()
{
DateTime initialTime;
int months;
DateTime resultingTime;
System.Globalization.Calendar myCalendar = new GregorianCalendar(GregorianCalendarTypes.USEnglish);
months = -1;
long maxTimeInTicks = myCalendar.MaxSupportedDateTime.Ticks;
long minTimeInTikcs = myCalendar.MinSupportedDateTime.Ticks;
initialTime = new DateTime(_generator.GetInt64(-55) % (maxTimeInTicks + 1));
resultingTime = myCalendar.AddMonths(initialTime, months);
VerifyAddMonthsResult(myCalendar, initialTime, resultingTime, months);
}
示例5: PosTest6
public void PosTest6()
{
DateTime initialTime;
int months;
DateTime resultingTime;
System.Globalization.Calendar myCalendar = new GregorianCalendar(GregorianCalendarTypes.USEnglish);
months = 48;
initialTime = myCalendar.ToDateTime(1996, 2, 29, 10, 30, 24, 0);
resultingTime = myCalendar.AddMonths(initialTime, months);
VerifyAddMonthsResult(myCalendar, initialTime, resultingTime, months);
}
示例6: NegTest3
public void NegTest3()
{
DateTime time;
int months;
System.Globalization.Calendar myCalendar;
myCalendar = new GregorianCalendar(GregorianCalendarTypes.USEnglish);
time = myCalendar.MaxSupportedDateTime;
months = 1;
Assert.Throws<ArgumentOutOfRangeException>(() =>
{
myCalendar.AddMonths(time, months);
});
}
示例7: NegTest2
public void NegTest2()
{
DateTime time;
int months;
System.Globalization.Calendar myCalendar;
time = DateTime.Now;
months = c_MAX_MONTHS_NUMBER + 1 + _generator.GetInt32(-55) % (int.MaxValue - c_MAX_MONTHS_NUMBER);
myCalendar = new GregorianCalendar(GregorianCalendarTypes.USEnglish);
Assert.Throws<ArgumentOutOfRangeException>(() =>
{
myCalendar.AddMonths(time, months);
});
}
示例8: GregorianAddMonth
[Test] // bug #81783
public void GregorianAddMonth ()
{
GregorianCalendar c = new GregorianCalendar ();
DateTime d = new DateTime (2007, 5, 31);
DateTime prev = c.AddMonths (d, -1);
Assert.AreEqual (4, prev.Month, "prev");
DateTime next = c.AddMonths (d, 1);
Assert.AreEqual (6, next.Month, "next");
d = new DateTime (2003, 12, 5);
prev = c.AddMonths (d, -13);
Assert.AreEqual (new DateTime (2002, 11, 5), prev, "prev2");
next = c.AddMonths (d, 6);
Assert.AreEqual (new DateTime (2004, 6, 5), next, "next2");
}
示例9: TestBug56688_4
public void TestBug56688_4()
{
XSSFWorkbook excel = XSSFTestDataSamples.OpenSampleWorkbook("56688_4.xlsx");
Calendar calendar = new GregorianCalendar(GregorianCalendarTypes.USEnglish);
DateTime time = calendar.AddMonths(DateTime.Now, 2);
double excelDate = DateUtil.GetExcelDate(time);
NumberEval eval = new NumberEval(Math.Floor(excelDate));
//CheckValue(excel, eval.StringValue + ".0");
CheckValue(excel, eval.StringValue);
}
示例10: ProcessUpKey
private void ProcessUpKey()
{
System.Globalization.Calendar _cal = new GregorianCalendar();
if (this.DisplayMode == CalendarMode.Month)
{
DateTime selectedDate = _cal.AddDays(this.SelectedDate.GetValueOrDefault(DateTime.Today), -7);
if (IsValidDate(this, selectedDate))
{
OnDayClick(selectedDate);
}
}
else
{
Debug.Assert(this.DisplayMode == CalendarMode.Year);
DateTime selectedMonth = _cal.AddMonths(this._selectedMonth, -4);
OnSelectedMonthChanged(selectedMonth);
}
}
示例11: ProcessEndKey
private void ProcessEndKey()
{
System.Globalization.Calendar _cal = new GregorianCalendar();
if (this.DisplayMode == CalendarMode.Month)
{
if (this.DisplayDate != null)
{
DateTime selectedDate = new DateTime(((DateTime)this.DisplayDate).Year, ((DateTime)this.DisplayDate).Month, 1);
selectedDate = _cal.AddMonths(selectedDate, 1);
selectedDate = _cal.AddDays(selectedDate, -1);
if (IsValidDate(this, selectedDate))
{
OnDayClick(selectedDate);
}
}
}
else
{
Debug.Assert(this.DisplayMode == CalendarMode.Year);
DateTime selectedMonth = new DateTime(this._selectedMonth.Year, 12, 1);
OnSelectedMonthChanged(selectedMonth);
}
}