本文整理汇总了C#中ZoneYearOffset.GetOccurrenceForYear方法的典型用法代码示例。如果您正苦于以下问题:C# ZoneYearOffset.GetOccurrenceForYear方法的具体用法?C# ZoneYearOffset.GetOccurrenceForYear怎么用?C# ZoneYearOffset.GetOccurrenceForYear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZoneYearOffset
的用法示例。
在下文中一共展示了ZoneYearOffset.GetOccurrenceForYear方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetOccurrenceForYear_Defaults_Epoch
public void GetOccurrenceForYear_Defaults_Epoch()
{
var offset = new ZoneYearOffset(TransitionMode.Utc, 1, 1, 0, true, LocalTime.Midnight);
var actual = offset.GetOccurrenceForYear(1970);
var expected = new LocalDateTime(1970, 1, 1, 0, 0).ToLocalInstant();
Assert.AreEqual(expected, actual);
}
示例2: GetOccurrenceForYear_Milliseconds
public void GetOccurrenceForYear_Milliseconds()
{
var offset = new ZoneYearOffset(TransitionMode.Utc, 1, 1, 0, true, new LocalTime(0, 0, 0, 1));
var actual = offset.GetOccurrenceForYear(1970);
var expected = new LocalDateTime(1970, 1, 1, 0, 0, 0, 1).ToLocalInstant();
Assert.AreEqual(expected, actual);
}
示例3: GetOccurrenceForYear_WithAddDay
public void GetOccurrenceForYear_WithAddDay()
{
// Last Thursday in October, then add 24 hours. The last Thursday in October 2013 is the 31st, so
// we should get the start of November 1st.
var offset = new ZoneYearOffset(TransitionMode.Utc, 10, -1, (int) IsoDayOfWeek.Thursday, false, LocalTime.Midnight, true);
var actual = offset.GetOccurrenceForYear(2013);
var expected = new LocalDateTime(2013, 11, 1, 0, 0).ToLocalInstant();
Assert.AreEqual(expected, actual);
}
示例4: GetOccurrenceForYear_WithAddDay_December31st9999
public void GetOccurrenceForYear_WithAddDay_December31st9999()
{
var offset = new ZoneYearOffset(TransitionMode.Utc, 12, 31, 0, false, LocalTime.Midnight, true);
var actual = offset.GetOccurrenceForYear(9999);
var expected = LocalInstant.AfterMaxValue;
Assert.AreEqual(expected, actual);
}
示例5: GetOccurrenceForYear_AtLeastFeb29th_NotLeapYear
public void GetOccurrenceForYear_AtLeastFeb29th_NotLeapYear()
{
ZoneYearOffset offset = new ZoneYearOffset(TransitionMode.Utc, 2, 29, (int) IsoDayOfWeek.Sunday, true, LocalTime.Midnight);
Assert.Throws<InvalidOperationException>(() => offset.GetOccurrenceForYear(2013));
}
示例6: GetOccurrenceForYear_AtMostFeb29th_NotLeapYear
public void GetOccurrenceForYear_AtMostFeb29th_NotLeapYear()
{
ZoneYearOffset offset = new ZoneYearOffset(TransitionMode.Utc, 2, 29, (int) IsoDayOfWeek.Sunday, false, LocalTime.Midnight);
var actual = offset.GetOccurrenceForYear(2013);
var expected = new LocalDateTime(2013, 2, 24, 0, 0).ToLocalInstant(); // Feb 24th is the last Sunday is February 2013
Assert.AreEqual(expected, actual);
}
示例7: GetOccurrenceForYear_AtLeastFeb29th_LeapYear
public void GetOccurrenceForYear_AtLeastFeb29th_LeapYear()
{
ZoneYearOffset offset = new ZoneYearOffset(TransitionMode.Utc, 2, 29, (int) IsoDayOfWeek.Sunday, true, LocalTime.Midnight);
var actual = offset.GetOccurrenceForYear(2012);
var expected = new LocalDateTime(2012, 3, 4, 0, 0).ToLocalInstant(); // March 4th is the first Sunday after 2012-02-29
Assert.AreEqual(expected, actual);
}
示例8: GetOccurrenceForYear_ExactlyFeb29th_NotLeapYear
public void GetOccurrenceForYear_ExactlyFeb29th_NotLeapYear()
{
ZoneYearOffset offset = new ZoneYearOffset(TransitionMode.Utc, 2, 29, 0, false, LocalTime.Midnight);
Assert.Throws<InvalidOperationException>(() => offset.GetOccurrenceForYear(2013));
}
示例9: GetOccurrenceForYear_ExactlyFeb29th_LeapYear
public void GetOccurrenceForYear_ExactlyFeb29th_LeapYear()
{
ZoneYearOffset offset = new ZoneYearOffset(TransitionMode.Utc, 2, 29, 0, false, LocalTime.Midnight);
var actual = offset.GetOccurrenceForYear(2012);
var expected = new LocalDateTime(2012, 2, 29, 0, 0).ToLocalInstant();
Assert.AreEqual(expected, actual);
}
示例10: GetOccurrenceForYear_LastSundayInOctober
public void GetOccurrenceForYear_LastSundayInOctober()
{
ZoneYearOffset offset = new ZoneYearOffset(TransitionMode.Utc, 10, -1, (int)IsoDayOfWeek.Sunday, false, LocalTime.Midnight);
var actual = offset.GetOccurrenceForYear(1996);
var expected = new LocalDateTime(1996, 10, 27, 0, 0).ToLocalInstant();
Assert.AreEqual(expected, actual);
}
示例11: GetOccurrenceForYear_WednesdayBackward
public void GetOccurrenceForYear_WednesdayBackward()
{
var offset = new ZoneYearOffset(TransitionMode.Utc, 1, 15, (int)DayOfWeek.Wednesday, false, LocalTime.Midnight);
var actual = offset.GetOccurrenceForYear(1970);
var expected = new LocalDateTime(1970, 1, 14, 0, 0).ToLocalInstant(); // 1970-01-15 was a Thursday
Assert.AreEqual(expected, actual);
}