public void GetZoneIntervals_GapAroundAndInTailZoneTransition() { // Tail zone is -10 / +5, with the transition occurring just after // the transition *to* the tail zone from the precalculated zone. // A local instant of one hour after the transition from the precalculated zone (which is -5) // will therefore be in the gap. No zone interval matches, so the result is // an empty pair. var tailZone = new SingleTransitionZone(ThirdInterval.End + Duration.FromHours(1), -10, +5); var gapZone = new PrecalculatedDateTimeZone("Test", new[] { FirstInterval, SecondInterval, ThirdInterval }, tailZone); var pair = gapZone.GetZoneIntervals(ThirdInterval.LocalEnd + Duration.FromHours(1)); Assert.IsNull(pair.EarlyInterval); Assert.IsNull(pair.LateInterval); }
public void GetZoneIntervals_SingleIntervalAroundTailZoneTransition() { // Tail zone is fixed at +5. A local instant of one hour before the transition // from the precalculated zone (which is -5) will therefore give an instant from // the tail zone which occurs before the precalculated-to-tail transition, // and can therefore be ignored, resulting in an overall unambiguous time. var tailZone = new FixedDateTimeZone(Offset.FromHours(5)); var gapZone = new PrecalculatedDateTimeZone("Test", new[] { FirstInterval, SecondInterval, ThirdInterval }, tailZone); var pair = gapZone.GetZoneIntervals(ThirdInterval.LocalEnd - Duration.FromHours(1)); Assert.AreEqual(ThirdInterval, pair.EarlyInterval); Assert.IsNull(pair.LateInterval); }
public void GetZoneIntervals_GapAroundTailZoneTransition() { // Tail zone is fixed at +5. A local instant of one hour after the transition // from the precalculated zone (which is -5) will therefore give an instant from // the tail zone which occurs before the precalculated-to-tail transition, // and can therefore be ignored, resulting in an overall gap. var tailZone = new FixedDateTimeZone(Offset.FromHours(5)); var gapZone = new PrecalculatedDateTimeZone("Test", new[] { FirstInterval, SecondInterval, ThirdInterval }, tailZone); var actual = gapZone.GetZoneIntervals(ThirdInterval.LocalEnd); var expected = ZoneIntervalPair.NoMatch; Assert.AreEqual(expected, actual); }
public void GetZoneIntervals_AmbiguousButTooEarlyInTailZoneTransition() { // Tail zone is +10 / +8, with the transition occurring just after // the transition *to* the tail zone from the precalculated zone. // A local instant of one hour before after the transition from the precalculated zone (which is -5) // will therefore be ambiguous, but the resulting instants from the ambiguity occur // before our transition into the tail zone, so are ignored. var tailZone = new SingleTransitionZone(ThirdInterval.End + Duration.FromHours(1), 10, 8); var gapZone = new PrecalculatedDateTimeZone("Test", new[] { FirstInterval, SecondInterval, ThirdInterval }, tailZone); var pair = gapZone.GetZoneIntervals(ThirdInterval.LocalEnd - Duration.FromHours(1)); Assert.AreEqual(ThirdInterval, pair.EarlyInterval); Assert.IsNull(pair.LateInterval); }