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


C# LocalDateTime.WithCalendar方法代码示例

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


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

示例1: WithCalendar

 public void WithCalendar()
 {
     LocalDateTime isoEpoch = new LocalDateTime(1970, 1, 1, 0, 0, 0);
     LocalDateTime julianEpoch = isoEpoch.WithCalendar(CalendarSystem.GetJulianCalendar(4));
     Assert.AreEqual(1969, julianEpoch.Year);
     Assert.AreEqual(12, julianEpoch.MonthOfYear);
     Assert.AreEqual(19, julianEpoch.DayOfMonth);
     Assert.AreEqual(isoEpoch.TimeOfDay, julianEpoch.TimeOfDay);
 }
开发者ID:manirana007,项目名称:NodaTime,代码行数:9,代码来源:LocalDateTimeTest.cs

示例2: CopticEpoch

        public void CopticEpoch()
        {
            CalendarSystem coptic = CalendarSystem.Coptic;
            LocalDateTime copticEpoch = new LocalDateTime(1, 1, 1, 0, 0, coptic);

            CalendarSystem julian = CalendarSystem.Julian;
            LocalDateTime converted = copticEpoch.WithCalendar(julian);

            LocalDateTime expected = new LocalDateTime(284, 8, 29, 0, 0, julian);
            Assert.AreEqual(expected, converted);
        }
开发者ID:ivandrofly,项目名称:nodatime,代码行数:11,代码来源:CopticCalendarSystemTest.cs

示例3: SampleDate2

        public void SampleDate2()
        {
            LocalDateTime ldt = new LocalDateTime(2005, 11, 26, 0, 0, 0, 0, CalendarSystem.Iso);
            ldt = ldt.WithCalendar(SampleCalendar);
            Assert.AreEqual(Era.AnnoHegirae, ldt.Era);
            Assert.AreEqual(1426, ldt.YearOfEra);

            Assert.AreEqual(1426, ldt.Year);
            Assert.AreEqual(10, ldt.Month);
            Assert.AreEqual(24, ldt.Day);
            Assert.AreEqual(IsoDayOfWeek.Saturday, ldt.IsoDayOfWeek);
            Assert.AreEqual(5 * 30 + 4 * 29 + 24, ldt.DayOfYear);
            Assert.AreEqual(0, ldt.Hour);
            Assert.AreEqual(0, ldt.Minute);
            Assert.AreEqual(0, ldt.Second);
            Assert.AreEqual(0, ldt.TickOfSecond);
        }
开发者ID:ivandrofly,项目名称:nodatime,代码行数:17,代码来源:IslamicCalendarSystemTest.cs

示例4: SampleDate1

        public void SampleDate1()
        {
            // Note: field checks removed from the tests.
            LocalDateTime ldt = new LocalDateTime(1945, 11, 12, 0, 0, 0, 0, CalendarSystem.Iso);

            ldt = ldt.WithCalendar(SampleCalendar);
            Assert.AreEqual(Era.AnnoHegirae, ldt.Era);
            Assert.AreEqual(1364, ldt.YearOfEra);

            Assert.AreEqual(1364, ldt.Year);
            Assert.AreEqual(12, ldt.Month);
            Assert.AreEqual(6, ldt.Day);
            Assert.AreEqual(IsoDayOfWeek.Monday, ldt.IsoDayOfWeek);
            Assert.AreEqual(6 * 30 + 5 * 29 + 6, ldt.DayOfYear);

            Assert.AreEqual(0, ldt.Hour);
            Assert.AreEqual(0, ldt.Minute);
            Assert.AreEqual(0, ldt.Second);
            Assert.AreEqual(0, ldt.TickOfSecond);
        }
开发者ID:ivandrofly,项目名称:nodatime,代码行数:20,代码来源:IslamicCalendarSystemTest.cs

示例5: SampleDate

        public void SampleDate()
        {
            CalendarSystem copticCalendar = CalendarSystem.Coptic;
            LocalDateTime iso = new LocalDateTime(2004, 6, 9, 0, 0, 0, 0);
            LocalDateTime coptic = iso.WithCalendar(copticCalendar);

            Assert.AreEqual(Era.AnnoMartyrum, coptic.Era);
            Assert.AreEqual(1720, coptic.YearOfEra);

            Assert.AreEqual(1720, coptic.Year);
            Assert.IsFalse(copticCalendar.IsLeapYear(1720));
        
            Assert.AreEqual(10, coptic.Month);
            Assert.AreEqual(2, coptic.Day);
            
            Assert.AreEqual(IsoDayOfWeek.Wednesday, coptic.IsoDayOfWeek);

            Assert.AreEqual(9 * 30 + 2, coptic.DayOfYear);

            Assert.AreEqual(0, coptic.Hour);
            Assert.AreEqual(0, coptic.Minute);
            Assert.AreEqual(0, coptic.Second);
            Assert.AreEqual(0, coptic.Millisecond);
        }
开发者ID:ivandrofly,项目名称:nodatime,代码行数:24,代码来源:CopticCalendarSystemTest.cs

示例6: Comparison_IgnoresOriginalCalendar

        public void Comparison_IgnoresOriginalCalendar()
        {
            LocalDateTime dateTime1 = new LocalDateTime(1900, 1, 1, 10, 30, 0);
            LocalDateTime dateTime2 = dateTime1.WithCalendar(CalendarSystem.Julian);

            // Calendar information is propagated into LocalDate, but not into LocalTime
            Assert.IsFalse(dateTime1.Date == dateTime2.Date);
            Assert.IsTrue(dateTime1.TimeOfDay == dateTime2.TimeOfDay);
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:9,代码来源:LocalTimeTest.Operators.cs


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