当前位置: 首页>>代码示例>>C#>>正文


C# GregorianCalendar.AddYears方法代码示例

本文整理汇总了C#中System.Globalization.GregorianCalendar.AddYears方法的典型用法代码示例。如果您正苦于以下问题:C# GregorianCalendar.AddYears方法的具体用法?C# GregorianCalendar.AddYears怎么用?C# GregorianCalendar.AddYears使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Globalization.GregorianCalendar的用法示例。


在下文中一共展示了GregorianCalendar.AddYears方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PosTest5

 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);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:11,代码来源:GregorianCalendarAddYears.cs

示例2: PosTest3

 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);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:11,代码来源:GregorianCalendarAddYears.cs

示例3: PosTest1

 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);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:11,代码来源:GregorianCalendarAddYears.cs

示例4: AddYears

 /// <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;
     }
 }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:18,代码来源:DateTimeHelper.cs

示例5: PosTest4

 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);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:13,代码来源:GregorianCalendarAddYears.cs

示例6: AddYearOnLeapYear

	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");
	}
开发者ID:GirlD,项目名称:mono,代码行数:9,代码来源:CalendarTest.cs

示例7: NegTest1

 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);
    });
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:13,代码来源:GregorianCalendarAddYears.cs

示例8: ProcessPageUpKey

 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);
     }
 } 
开发者ID:dfr0,项目名称:moon,代码行数:18,代码来源:Calendar.cs


注:本文中的System.Globalization.GregorianCalendar.AddYears方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。