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


C# LocalDateTime.PlusYears方法代码示例

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


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

示例1: PlusYear_LeapToNonLeap

        public void PlusYear_LeapToNonLeap()
        {
            LocalDateTime start = new LocalDateTime(2012, 2, 29, 12, 15, 8);
            LocalDateTime expected = new LocalDateTime(2013, 2, 28, 12, 15, 8);
            Assert.AreEqual(expected, start.PlusYears(1));

            expected = new LocalDateTime(2011, 2, 28, 12, 15, 8);
            Assert.AreEqual(expected, start.PlusYears(-1));
        }
开发者ID:manirana007,项目名称:NodaTime,代码行数:9,代码来源:LocalDateTimeTest.PlusUnit.cs

示例2: PlusYear_Simple

        public void PlusYear_Simple()
        {
            LocalDateTime start = new LocalDateTime(2011, 6, 26, 12, 15, 8);
            LocalDateTime expected = new LocalDateTime(2016, 6, 26, 12, 15, 8);
            Assert.AreEqual(expected, start.PlusYears(5));

            expected = new LocalDateTime(2006, 6, 26, 12, 15, 8);
            Assert.AreEqual(expected, start.PlusYears(-5));
        }
开发者ID:manirana007,项目名称:NodaTime,代码行数:9,代码来源:LocalDateTimeTest.PlusUnit.cs

示例3: PlusYears_DoesNotTruncateFromOneLeapYearToAnother

        public void PlusYears_DoesNotTruncateFromOneLeapYearToAnother()
        {
            var calendar = CalendarSystem.GetIslamicCalendar(IslamicLeapYearPattern.Base15, IslamicEpoch.Civil);
            Assert.IsTrue(calendar.IsLeapYear(2));
            Assert.IsTrue(calendar.IsLeapYear(5));

            LocalDateTime start = new LocalDateTime(2, 12, 30, 2, 0, calendar);
            LocalDateTime expectedEnd = new LocalDateTime(5, 12, 30, 2, 0, calendar);

            Assert.AreEqual(expectedEnd, start.PlusYears(3));
        }
开发者ID:ivandrofly,项目名称:nodatime,代码行数:11,代码来源:IslamicCalendarSystemTest.cs

示例4: PlusYears_TruncatesAtLeapYear

        public void PlusYears_TruncatesAtLeapYear()
        {
            var calendar = CalendarSystem.GetIslamicCalendar(IslamicLeapYearPattern.Base15, IslamicEpoch.Civil);
            Assert.IsTrue(calendar.IsLeapYear(2));
            Assert.IsFalse(calendar.IsLeapYear(3));

            LocalDateTime start = new LocalDateTime(2, 12, 30, 2, 0, calendar);
            LocalDateTime expectedEnd = new LocalDateTime(3, 12, 29, 2, 0, calendar);

            Assert.AreEqual(expectedEnd, start.PlusYears(1));
        }
开发者ID:ivandrofly,项目名称:nodatime,代码行数:11,代码来源:IslamicCalendarSystemTest.cs

示例5: PlusYears_Simple

 public void PlusYears_Simple()
 {
     var calendar = CalendarSystem.GetIslamicCalendar(IslamicLeapYearPattern.Base15, IslamicEpoch.Civil);
     LocalDateTime start = new LocalDateTime(5, 8, 20, 2, 0, calendar);
     LocalDateTime expectedEnd = new LocalDateTime(10, 8, 20, 2, 0, calendar);
     Assert.AreEqual(expectedEnd, start.PlusYears(5));
 }
开发者ID:ivandrofly,项目名称:nodatime,代码行数:7,代码来源:IslamicCalendarSystemTest.cs

示例6: PlusYear_LeapToLeap

 public void PlusYear_LeapToLeap()
 {
     LocalDateTime start = new LocalDateTime(2012, 2, 29, 12, 15, 8);
     LocalDateTime expected = new LocalDateTime(2016, 2, 29, 12, 15, 8);
     Assert.AreEqual(expected, start.PlusYears(4));
 }
开发者ID:manirana007,项目名称:NodaTime,代码行数:6,代码来源:LocalDateTimeTest.PlusUnit.cs


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