public void PreviousOrSameTwice_LastYear()
        {
            var        januaryFirstMidnight = new ZoneYearOffset(TransitionMode.Utc, 1, 1, 0, true, LocalTime.Midnight);
            var        recurrence           = new ZoneRecurrence("bob", Offset.Zero, januaryFirstMidnight, 1970, 1973);
            Transition?actual = recurrence.PreviousOrSame(Instant.FromUtc(1972, 1, 1, 0, 0) - Duration.Epsilon, Offset.Zero, Offset.Zero);

            actual = recurrence.PreviousOrSame(actual.Value.Instant - Duration.Epsilon, Offset.Zero, Offset.Zero);
            Transition?expected = new Transition(NodaConstants.UnixEpoch, Offset.Zero);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 2
0
 public void PreviousOrSame_LastYear()
 {
     var januaryFirstMidnight = new ZoneYearOffset(TransitionMode.Utc, 1, 1, 0, true, LocalTime.Midnight);
     var recurrence = new ZoneRecurrence("bob", Offset.Zero, januaryFirstMidnight, 1970, 1972);
     Transition? actual = recurrence.PreviousOrSame(Instant.FromUtc(1971, 1, 1, 0, 0) - Duration.Epsilon, Offset.Zero, Offset.Zero);
     Transition? expected = new Transition(NodaConstants.UnixEpoch, Offset.Zero);
     Assert.AreEqual(expected, actual);
 }
Esempio n. 3
0
 public void PreviousOrSame_AfterLastYear()
 {
     var januaryFirstMidnight = new ZoneYearOffset(TransitionMode.Utc, 1, 1, 0, true, LocalTime.Midnight);
     var recurrence = new ZoneRecurrence("bob", Offset.Zero, januaryFirstMidnight, 1970, 1972);
     Transition? actual = recurrence.PreviousOrSame(Instant.MaxValue, Offset.Zero, Offset.Zero);
     Transition? expected = new Transition(Instant.FromUtc(1972, 1, 1, 0, 0), Offset.Zero);
     Assert.AreEqual(expected, actual);
 }
        public void PreviousOrSame_AfterLastYear()
        {
            var        januaryFirstMidnight = new ZoneYearOffset(TransitionMode.Utc, 1, 1, 0, true, LocalTime.Midnight);
            var        recurrence           = new ZoneRecurrence("bob", Offset.Zero, januaryFirstMidnight, 1970, 1972);
            Transition?actual   = recurrence.PreviousOrSame(Instant.MaxValue, Offset.Zero, Offset.Zero);
            Transition?expected = new Transition(Instant.FromUtc(1972, 1, 1, 0, 0), Offset.Zero);

            Assert.AreEqual(expected, actual);
        }
        public void PreviousOrSame_IncludesGivenInstant()
        {
            var january10thMidnight = new ZoneYearOffset(TransitionMode.Utc, 1, 10, 0, true, LocalTime.Midnight);
            var recurrence          = new ZoneRecurrence("x", Offset.Zero, january10thMidnight, 2000, 3000);
            var transition          = Instant.FromUtc(2500, 1, 10, 0, 0);
            var next = recurrence.PreviousOrSame(transition, Offset.Zero, Offset.Zero);

            Assert.AreEqual(transition, next.Value.Instant);
        }
        public void PreviousOrSame_BeforeFirstYear_null()
        {
            var        januaryFirstMidnight = new ZoneYearOffset(TransitionMode.Utc, 1, 1, 0, true, LocalTime.Midnight);
            var        recurrence           = new ZoneRecurrence("bob", Offset.Zero, januaryFirstMidnight, 1970, 1972);
            Transition?actual   = recurrence.PreviousOrSame(NodaConstants.UnixEpoch - Duration.Epsilon, Offset.Zero, Offset.Zero);
            Transition?expected = null;

            Assert.AreEqual(expected, actual);
        }
        public void PreviousOrSame_OnFirstYear_null()
        {
            // Transition is on January 2nd, but we're asking for January 1st.
            var        januaryFirstMidnight = new ZoneYearOffset(TransitionMode.Utc, 1, 2, 0, true, LocalTime.Midnight);
            var        recurrence           = new ZoneRecurrence("bob", Offset.Zero, januaryFirstMidnight, 1970, 1972);
            Transition?actual   = recurrence.PreviousOrSame(NodaConstants.UnixEpoch, Offset.Zero, Offset.Zero);
            Transition?expected = null;

            Assert.AreEqual(expected, actual);
        }
Esempio n. 8
0
 public void PreviousOrSame_IncludesGivenInstant()
 {
     var january10thMidnight = new ZoneYearOffset(TransitionMode.Utc, 1, 10, 0, true, LocalTime.Midnight);
     var recurrence = new ZoneRecurrence("x", Offset.Zero, january10thMidnight, 2000, 3000);
     var transition = Instant.FromUtc(2500, 1, 10, 0, 0);
     var next = recurrence.PreviousOrSame(transition, Offset.Zero, Offset.Zero);
     Assert.AreEqual(transition, next.Value.Instant);
 }
Esempio n. 9
0
 public void PreviousOrSame_OnFirstYear_null()
 {
     // Transition is on January 2nd, but we're asking for January 1st.
     var januaryFirstMidnight = new ZoneYearOffset(TransitionMode.Utc, 1, 2, 0, true, LocalTime.Midnight);
     var recurrence = new ZoneRecurrence("bob", Offset.Zero, januaryFirstMidnight, 1970, 1972);
     Transition? actual = recurrence.PreviousOrSame(NodaConstants.UnixEpoch, Offset.Zero, Offset.Zero);
     Transition? expected = null;
     Assert.AreEqual(expected, actual);
 }