本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}