コード例 #1
0
        public void IsDaylightSavingsTimeAutumnTest()
        {
            var bstLastValidTime      = new LocalDateTime(2020, 10, 25, 0, 59, 59).InZoneStrictly(_zoneGmt).ToInstant();     //  Instant for 00:59:59 BST which is 24-10-20 23:59:59 GMT
            var bstFirstAmbiguousTime = bstLastValidTime.Plus(Duration.FromSeconds(1));                                      //   Instance for 01:00:00 BST - ambiguous
            var bstLastAmbiguousTime  = bstFirstAmbiguousTime.Plus(Duration.FromMinutes(59).Plus(Duration.FromSeconds(59))); //   Instance for 01:59:59 BST - ambiguous
            var bstFirstValidTime     = bstLastValidTime.Plus(Duration.FromHours(2).Plus(Duration.FromSeconds(1)));          //  Instant for 02:00:00 GMT

            Assert.True(_zoneGmt.IsDaylightSavingsTime(bstLastValidTime));
            Assert.True(_zoneGmt.IsDaylightSavingsTime(bstFirstAmbiguousTime));
            Assert.True(_zoneGmt.IsDaylightSavingsTime(bstLastAmbiguousTime));
            Assert.False(_zoneGmt.IsDaylightSavingsTime(bstFirstValidTime));
        }
コード例 #2
0
        public void InstantToStringDsAutumnTest()
        {
            var bstLastValidTime      = new LocalDateTime(2020, 10, 25, 0, 59, 59).InZoneStrictly(_zoneGmt).ToInstant();     //  Instant for 00:59:59 BST which is 24-10-20 23:59:59 GMT
            var bstFirstAmbiguousTime = bstLastValidTime.Plus(Duration.FromSeconds(1));                                      //   Instance for 01:00:00 BST - ambiguous
            var bstLastAmbiguousTime  = bstFirstAmbiguousTime.Plus(Duration.FromMinutes(59).Plus(Duration.FromSeconds(59))); //   Instance for 01:59:59 BST - ambiguous
            var bstFirstValidTime     = bstLastValidTime.Plus(Duration.FromHours(2).Plus(Duration.FromSeconds(1)));          //  Instant for 02:00:00 GMT - end of daylight saving

            //PASS
            Assert.Equal("25-10-2020 00:59:59", bstLastValidTime.ToString("en-GB", _zoneGmt, false, MxCultureInfo.FormatType.DateTime, true));
            //FAIL - clocks move back at 1:00:00 AM GMT (equiv 02:00:00 BST) so times between 01:59:59 BST and 01:00:00 BST are ambiguous
            Assert.Equal("[error: ambiguous time]", bstFirstAmbiguousTime.ToString("en-GB", _zoneGmt, false, MxCultureInfo.FormatType.DateTime, true));
            Assert.Equal("[error: ambiguous time]", bstLastAmbiguousTime.ToString("en-GB", _zoneGmt, false, MxCultureInfo.FormatType.DateTime, true));
            //PASS
            Assert.Equal("25-10-2020 02:00:00", bstFirstValidTime.ToString("en-GB", _zoneGmt, false, MxCultureInfo.FormatType.DateTime, true));
        }
コード例 #3
0
        public void BoundaryTest()
        {
            var list  = new List <ValueTick>();
            var date1 = new LocalDateTime(2000, 1, 1, 0, 0).InUtc().ToInstant();
            var date2 = new LocalDateTime(2000, 1, 2, 0, 0).InUtc().ToInstant();

            list.Add(new ValueTick {
                Date = date1, Value = 0
            });
            list.Add(new ValueTick {
                Date = date2, Value = 0
            });

            var result = list.InterpolateValue(date1);

            Assert.False(double.IsNaN(result)); // enough data

            result = list.InterpolateValue(date1.Plus(Duration.FromHours(-7 * 24)));
            Assert.True(double.IsNaN(result)); // not enough data

            result = list.InterpolateValue(date2);
            Assert.False(double.IsNaN(result)); // enough data

            result = list.InterpolateValue(date2.Plus(Duration.FromHours(7 * 24)));
            Assert.True(double.IsNaN(result)); // not enough data
        }
 public Answer GetAnswer(Question question)
 {
     var cityToken = question.GetToken<CityToken>();
     var dateToken = question.GetToken<DateToken>();
     int? year = null;
     if (dateToken != null) year = dateToken.Year;
     DaylightSavingInformation daylightSavingInfo;
     if (year.HasValue)
     {
         var firstDateInTheYear = new LocalDateTime(year.Value, 1, 1, 0, 0).InZone(DateTimeZoneProviders.Tzdb[cityToken.City.Timezone], Resolvers.LenientResolver);
         var firstZoneIntervalInTheYear = firstDateInTheYear.GetZoneInterval();
         if (firstZoneIntervalInTheYear.IsoLocalEnd.Year > 10000) {
             daylightSavingInfo = DaylightSavingInformation.CreateWithNoDaylightSavings();
         }
         else
         {
             var firstDateInTheNextZoneInterval = firstDateInTheYear.Plus(firstZoneIntervalInTheYear.Duration).Plus(Duration.FromMilliseconds(1));
             daylightSavingInfo = GetDaylightSavingInfo(firstDateInTheNextZoneInterval);
         }
     }
     else
     {
         daylightSavingInfo = GetDaylightSavingInfo(cityToken.GetCurrentTime());
     }
     var answerText = GetFormattedDaylightSavingInfo(daylightSavingInfo, cityToken.City);
     return new Answer(question, true, true, answerText);
 }
コード例 #5
0
        public void IsDaylightSavingsTimeSpringTest()
        {
            var gmtEndingSpring = new LocalDateTime(2020, 03, 29, 00, 59, 59).InZoneStrictly(_zoneGmt).ToInstant(); //Instant for 00:59:59 GMT
            var bstStartsSpring = gmtEndingSpring.Plus(Duration.FromSeconds(1));                                    //Instant for 01:00:00 GMT which is 02:00:00 BST - start of daylight saving

            Assert.False(_zoneGmt.IsDaylightSavingsTime(gmtEndingSpring));
            Assert.True(_zoneGmt.IsDaylightSavingsTime(bstStartsSpring));
        }
コード例 #6
0
    public void Future_with_options()
    {
        var starting = new LocalDateTime(2015, 6, 6, 4, 17, 41);

        dataSet.Future(reference: starting, daysToGoForward: 500).Should()
        .BeLessOrEqualTo(starting.Plus(Period.FromDays(500)))
        .And
        .BeGreaterOrEqualTo(starting);
    }
コード例 #7
0
        public void InstantToStringDsSpringTest()
        {
            var gmtEndingSpring = new LocalDateTime(2020, 03, 29, 00, 59, 59).InZoneStrictly(_zoneGmt).ToInstant();  //Instant for 0:59:59 GMT
            var bstStartsSpring = gmtEndingSpring.Plus(Duration.FromSeconds(1));                                     //Instant for 1:00:00 GMT which is 2:00:00 BST - start of daylight saving

            Assert.Equal("29-03-2020 00:59:59", gmtEndingSpring.ToString("en-GB", _zoneGmt, false, MxCultureInfo.FormatType.DateTime, true));
            //clocks move forward at 1:00 AM GMT so BST times between 01:00:00 GMT and 01:59:59 GMT are invalid
            Assert.Equal("29-03-2020 02:00:00", bstStartsSpring.ToString("en-GB", _zoneGmt, false, MxCultureInfo.FormatType.DateTime, true));
        }
コード例 #8
0
    public void Future()
    {
        var starting = new LocalDateTime(2015, 6, 6, 4, 17, 41);

        dataSet.Future(reference: starting).Should()
        .BeLessOrEqualTo(starting.Plus(Period.FromDays(100)))
        .And
        .BeGreaterOrEqualTo(starting);
    }
コード例 #9
0
        // No tests for non-ISO-day-of-week calendars as we don't have any yet.

        public void Operator_MethodEquivalents()
        {
            LocalDateTime start  = new LocalDateTime(2011, 1, 1, 15, 25, 30, 100, 5000);
            Period        period = Period.FromHours(1) + Period.FromDays(1);

            Assert.AreEqual(start + period, LocalDateTime.Add(start, period));
            Assert.AreEqual(start + period, start.Plus(period));
            Assert.AreEqual(start - period, LocalDateTime.Subtract(start, period));
            Assert.AreEqual(start - period, start.Minus(period));
        }
コード例 #10
0
        public LocalDateTime?ComputeNextRetryTime(LocalDateTime firstExecutionTime, LocalDateTime lastExecutionTime)
        {
            var nextExecutionTime = lastExecutionTime.Plus(this._minimalRetryInterval);

            if (nextExecutionTime < firstExecutionTime.Plus(this._allowableDuration))
            {
                return(nextExecutionTime);
            }

            return(null);
        }
コード例 #11
0
        public void Plus_FullPeriod()
        {
            LocalDateTime start  = new LocalDateTime(2011, 4, 2, 12, 15, 8);
            var           period = new PeriodBuilder {
                Years   = 1, Months = 2, Weeks = 3, Days = 4, Hours = 5, Minutes = 6,
                Seconds = 7, Milliseconds = 8, Ticks = 9
            }.Build();
            var actual   = start.Plus(period);
            var expected = new LocalDateTime(2012, 6, 27, 17, 21, 15, 8, 9);

            Assert.AreEqual(expected, actual);
        }
コード例 #12
0
        public void Plus_FullPeriod()
        {
            LocalDateTime start  = new LocalDateTime(2011, 4, 2, 12, 15, 8);
            var           period = new PeriodBuilder {
                Years   = 1, Months = 2, Weeks = 3, Days = 4, Hours = 5, Minutes = 6,
                Seconds = 7, Milliseconds = 8, Ticks = 9, Nanoseconds = 11
            }.Build();
            var actual   = start.Plus(period);
            var expected = new LocalDateTime(2012, 6, 27, 17, 21, 15).PlusNanoseconds(8000911);

            Assert.AreEqual(expected, actual, $"{expected:yyyy-MM-dd HH:mm:ss.fffffffff} != {actual:yyyy-MM-dd HH:mm:ss.fffffffff}");
        }
コード例 #13
0
        public void Addition_Duration()
        {
            // Test all three approaches... not bothering to check a different calendar,
            // but we'll use two different offsets.
            OffsetDateTime start    = new LocalDateTime(2014, 08, 14, 6, 51).WithOffset(Offset.FromHours(1));
            Duration       duration = Duration.FromHours(8) + Duration.FromMinutes(9);
            OffsetDateTime expected = new LocalDateTime(2014, 08, 14, 15, 0).WithOffset(Offset.FromHours(1));

            Assert.AreEqual(expected, start + duration);
            Assert.AreEqual(expected, start.Plus(duration));
            Assert.AreEqual(expected, OffsetDateTime.Add(start, duration));
        }
コード例 #14
0
        public void Plus_FullPeriod()
        {
            // Period deliberately chosen to require date rollover
            LocalDateTime start  = new LocalDateTime(2011, 4, 2, 12, 15, 8);
            var           period = new PeriodBuilder {
                Years   = 1, Months = 2, Weeks = 3, Days = 4, Hours = 15, Minutes = 6,
                Seconds = 7, Milliseconds = 8, Ticks = 9, Nanoseconds = 11
            }.Build();
            var actual   = start.Plus(period);
            var expected = new LocalDateTime(2012, 6, 28, 3, 21, 15).PlusNanoseconds(8000911);

            Assert.AreEqual(expected, actual, $"{expected:uuuu-MM-dd HH:mm:ss.fffffffff} != {actual:uuuu-MM-dd HH:mm:ss.fffffffff}");
        }
コード例 #15
0
        public void Operator_MethodEquivalents()
        {
            LocalDateTime start  = new LocalDateTime(2011, 1, 1, 15, 25, 30).PlusNanoseconds(123456789);
            Period        period = Period.FromHours(1) + Period.FromDays(1);
            LocalDateTime end    = start + period;

            Assert.AreEqual(start + period, LocalDateTime.Add(start, period));
            Assert.AreEqual(start + period, start.Plus(period));
            Assert.AreEqual(start - period, LocalDateTime.Subtract(start, period));
            Assert.AreEqual(start - period, start.Minus(period));
            Assert.AreEqual(period, end - start);
            Assert.AreEqual(period, LocalDateTime.Subtract(end, start));
            Assert.AreEqual(period, end.Minus(start));
        }
コード例 #16
0
        public void InterpolateTest1()
        {
            var list = new List <ValueTick>();

            var date1 = new LocalDateTime(2000, 1, 1, 0, 0).InUtc().ToInstant();
            var date2 = new LocalDateTime(2000, 1, 5, 0, 0).InUtc().ToInstant();

            list.Add(new ValueTick {
                Date = date1, Value = 1
            });
            list.Add(new ValueTick {
                Date = date2, Value = 2
            });

            var result = list.InterpolateValue(date1.Plus(Duration.FromDays(1)));

            Assert.Equal(1.25, result);
        }
コード例 #17
0
        public void StringParseDateTimeToInstantDsSpringTest()
        {
            var gmtEndingSpring = new LocalDateTime(2020, 03, 29, 00, 59, 59).InZoneStrictly(_zoneGmt).ToInstant(); //Instant for 00:59:59 GMT
            var bstStartsSpring = gmtEndingSpring.Plus(Duration.FromSeconds(1));                                    //Instant for 01:00:00 GMT which is 02:00:00 BST - start of daylight saving
                                                                                                                    //PASS
            var text = "29-03-2020 00:59:59";                                                                       //March 29 2020, 00:59:59 GMT - 1 sec before daylight saving starts

            Assert.True(text.ParseDateTime(_zoneGmt, "en-GB", false, MxCultureInfo.FormatType.DateTime, true, out var result));
            Assert.Equal(gmtEndingSpring, result);
            //FAIL
            text = "29-03-2020 01:00:00";       //clocks move forward at 1:00:00 GMT so BST times between 01:00:00 GMT and 01:59:59 GMT are invalid
            Assert.False(text.ParseDateTime(_zoneGmt, "en-GB", false, MxCultureInfo.FormatType.DateTime, true, out result));
            text = "29-03-2020 01:59:59";
            Assert.False(text.ParseDateTime(_zoneGmt, "en-GB", false, MxCultureInfo.FormatType.DateTime, true, out result));
            //PASS
            text = "29-03-2020 02:00:00";       //March 29 2020, 02:00:00 BST (01:00:00 GMT)  - daylight saving  starts
            Assert.True(text.ParseDateTime(_zoneGmt, "en-GB", false, MxCultureInfo.FormatType.DateTime, true, out result));
            Assert.Equal(bstStartsSpring, result);
        }
コード例 #18
0
        public void StringParseDateTimeToInstantDsAutumnTest()
        {
            var bstLastValidTime  = new LocalDateTime(2020, 10, 25, 0, 59, 59).InZoneStrictly(_zoneGmt).ToInstant(); //  Instant for 00:59:59 BST which is 24-10-20 23:59:59 GMT
            var bstFirstValidTime = bstLastValidTime.Plus(Duration.FromHours(2).Plus(Duration.FromSeconds(1)));      //  Instant for 02:00:00 GMT
                                                                                                                     //PASS
            var text = "25-10-2020 00:59:59";                                                                        //Oct 25 2020, 00:59:59 BST (24-10-20, 23:59:59 GMT) - 1 hour 1 sec before daylight saving ends

            Assert.True(text.ParseDateTime(_zoneGmt, "en-GB", false, MxCultureInfo.FormatType.DateTime, true, out var result));
            Assert.Equal(bstLastValidTime, result);
            //FAIL
            text = "25-10-2020 01:00:00";       //clocks move back at 2:00:00 BST (01:00:00 GMT) so times between 01:00:00 BST and 01:59:59 BST are ambiguous
            Assert.False(text.ParseDateTime(_zoneGmt, "en-GB", false, MxCultureInfo.FormatType.DateTime, true, out result));
            text = "25-10-2020 01:59:59";
            Assert.False(text.ParseDateTime(_zoneGmt, "en-GB", false, MxCultureInfo.FormatType.DateTime, true, out result));
            //PASS
            text = "25-10-2020 02:00:00";       //Oct 25 2020, 2:00:00 GMT
            Assert.True(text.ParseDateTime(_zoneGmt, "en-GB", false, MxCultureInfo.FormatType.DateTime, true, out result));
            Assert.Equal(bstFirstValidTime, result);
        }
コード例 #19
0
        public void Can_Query_By_LessThan_LocalDateTime_Stored_As_DateTime2()
        {
            var           timeZone            = DateTimeZoneProviders.Tzdb.GetSystemDefault();
            LocalDateTime startLocalDateTime  = TestClock.Now.InZone(timeZone).LocalDateTime.Minus(Period.FromHours(1));
            LocalDateTime finishLocalDateTime = startLocalDateTime.PlusHours(3);
            var           testEvent           = new LocalDateTimeTestEntity
            {
                Description         = "Can_Query_By_LessThan_LocalDateTime_Stored_As_DateTime2",
                StartLocalDateTime  = startLocalDateTime,
                FinishLocalDateTime = finishLocalDateTime
            };

            using (ISession session = SessionFactory.OpenSession())
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.Save(testEvent);
                    transaction.Commit();
                }

            LocalDateTime beforeLocalDateTime = startLocalDateTime.Plus(Period.FromHours(1));

            using (ISession session = SessionFactory.OpenSession())
                using (ITransaction transaction = session.BeginTransaction())
                {
                    var query = session.Query <LocalDateTimeTestEntity>()
                                .Where(x => x.Id == testEvent.Id && x.StartLocalDateTime < beforeLocalDateTime);
                    var retrievedEvent = query.SingleOrDefault();
                    transaction.Commit();
                    Assert.That(testEvent, Is.Not.Null);
                    Assert.That(testEvent, Is.EqualTo(retrievedEvent));
                }

            using (ISession session = SessionFactory.OpenSession())
                using (ITransaction transaction = session.BeginTransaction())
                {
                    var query = session.Query <LocalDateTimeTestEntity>()
                                .Where(x => x.Id == testEvent.Id && x.StartLocalDateTime < beforeLocalDateTime && x.FinishLocalDateTime <= finishLocalDateTime);
                    var retrievedEvent = query.SingleOrDefault();
                    transaction.Commit();
                    Assert.That(testEvent, Is.Not.Null);
                    Assert.That(testEvent, Is.EqualTo(retrievedEvent));
                }
        }
コード例 #20
0
        public void BoundaryLimitTest()
        {
            var list  = new List <ValueTick>();
            var date1 = new LocalDateTime(2000, 1, 1, 0, 0).InUtc().ToInstant();
            var date2 = new LocalDateTime(2000, 1, 2, 0, 0).InUtc().ToInstant();

            list.Add(new ValueTick {
                Date = date1, Value = 1
            });
            list.Add(new ValueTick {
                Date = date2, Value = 2
            });

            var result = list.InterpolateValue(date2.PlusTicks(1));

            Assert.Equal(2, result);

            result = list.InterpolateValue(date2.Plus(Duration.FromHours(7 * 24)));
            Assert.True(double.IsNaN(result)); // not enough data
        }
コード例 #21
0
        public void Addition_Duration()
        {
            const int  minutes      = 23;
            const int  hours        = 3;
            const int  milliseconds = 40000;
            const long seconds      = 321;
            const long nanoseconds  = 12345;
            const long ticks        = 5432112345;

            // Test all three approaches... not bothering to check a different calendar,
            // but we'll use two different offsets.
            OffsetDateTime start    = new LocalDateTime(2014, 08, 14, 6, 51).WithOffset(Offset.FromHours(1));
            Duration       duration = Duration.FromHours(8) + Duration.FromMinutes(9);
            OffsetDateTime expected = new LocalDateTime(2014, 08, 14, 15, 0).WithOffset(Offset.FromHours(1));

            Assert.AreEqual(expected, start + duration);
            Assert.AreEqual(expected, start.Plus(duration));
            Assert.AreEqual(expected, OffsetDateTime.Add(start, duration));

            Assert.AreEqual(start + Duration.FromHours(hours), start.PlusHours(hours));
            Assert.AreEqual(start + Duration.FromHours(-hours), start.PlusHours(-hours));

            Assert.AreEqual(start + Duration.FromMinutes(minutes), start.PlusMinutes(minutes));
            Assert.AreEqual(start + Duration.FromMinutes(-minutes), start.PlusMinutes(-minutes));

            Assert.AreEqual(start + Duration.FromSeconds(seconds), start.PlusSeconds(seconds));
            Assert.AreEqual(start + Duration.FromSeconds(-seconds), start.PlusSeconds(-seconds));

            Assert.AreEqual(start + Duration.FromMilliseconds(milliseconds), start.PlusMilliseconds(milliseconds));
            Assert.AreEqual(start + Duration.FromMilliseconds(-milliseconds), start.PlusMilliseconds(-milliseconds));

            Assert.AreEqual(start + Duration.FromTicks(ticks), start.PlusTicks(ticks));
            Assert.AreEqual(start + Duration.FromTicks(-ticks), start.PlusTicks(-ticks));

            Assert.AreEqual(start + Duration.FromNanoseconds(nanoseconds), start.PlusNanoseconds(nanoseconds));
            Assert.AreEqual(start + Duration.FromNanoseconds(-nanoseconds), start.PlusNanoseconds(-nanoseconds));
        }
コード例 #22
0
 public void Plus_FullPeriod()
 {
     LocalDateTime start = new LocalDateTime(2011, 4, 2, 12, 15, 8);
     var period = new PeriodBuilder { Years = 1, Months = 2, Weeks = 3, Days = 4, Hours = 5, Minutes = 6,
                                      Seconds = 7, Milliseconds = 8, Ticks = 9 }.Build();
     var actual = start.Plus(period);
     var expected = new LocalDateTime(2012, 6, 27, 17, 21, 15, 8, 9);
     Assert.AreEqual(expected, actual);
 }
コード例 #23
0
 /// <summary>
 /// Add period
 /// </summary>
 /// <param name="ts"></param>
 /// <param name="period"></param>
 /// <returns></returns>
 public static LocalDateTime Add(this LocalDateTime ts, Period period) => ts.Plus(period);
コード例 #24
0
 public void Operator_MethodEquivalents()
 {
     LocalDateTime start = new LocalDateTime(2011, 1, 1, 15, 25, 30, 100, 5000);
     Period period = Period.FromHours(1) + Period.FromDays(1);
     LocalDateTime end = start + period;
     Assert.AreEqual(start + period, LocalDateTime.Add(start, period));
     Assert.AreEqual(start + period, start.Plus(period));
     Assert.AreEqual(start - period, LocalDateTime.Subtract(start, period));
     Assert.AreEqual(start - period, start.Minus(period));
     Assert.AreEqual(period, end - start);
     Assert.AreEqual(period, LocalDateTime.Subtract(end, start));
     Assert.AreEqual(period, end.Minus(start));
 }
コード例 #25
0
 public void Addition_Duration()
 {
     // Test all three approaches... not bothering to check a different calendar,
     // but we'll use two different offsets.
     OffsetDateTime start = new LocalDateTime(2014, 08, 14, 6, 51).WithOffset(Offset.FromHours(1));
     Duration duration = Duration.FromHours(8) + Duration.FromMinutes(9);
     OffsetDateTime expected = new LocalDateTime(2014, 08, 14, 15, 0).WithOffset(Offset.FromHours(1));
     Assert.AreEqual(expected, start + duration);
     Assert.AreEqual(expected, start.Plus(duration));
     Assert.AreEqual(expected, OffsetDateTime.Add(start, duration));
 }
コード例 #26
0
        public void Addition_Duration()
        {
            const int minutes = 23;
            const int hours = 3;
            const int milliseconds = 40000;
            const long seconds = 321;
            const long nanoseconds = 12345;
            const long ticks = 5432112345;

            // Test all three approaches... not bothering to check a different calendar,
            // but we'll use two different offsets.
            OffsetDateTime start = new LocalDateTime(2014, 08, 14, 6, 51).WithOffset(Offset.FromHours(1));
            Duration duration = Duration.FromHours(8) + Duration.FromMinutes(9);
            OffsetDateTime expected = new LocalDateTime(2014, 08, 14, 15, 0).WithOffset(Offset.FromHours(1));
            Assert.AreEqual(expected, start + duration);
            Assert.AreEqual(expected, start.Plus(duration));
            Assert.AreEqual(expected, OffsetDateTime.Add(start, duration));

            Assert.AreEqual(start + Duration.FromHours(hours), start.PlusHours(hours));
            Assert.AreEqual(start + Duration.FromHours(-hours), start.PlusHours(-hours));

            Assert.AreEqual(start + Duration.FromMinutes(minutes), start.PlusMinutes(minutes));
            Assert.AreEqual(start + Duration.FromMinutes(-minutes), start.PlusMinutes(-minutes));

            Assert.AreEqual(start + Duration.FromSeconds(seconds), start.PlusSeconds(seconds));
            Assert.AreEqual(start + Duration.FromSeconds(-seconds), start.PlusSeconds(-seconds));

            Assert.AreEqual(start + Duration.FromMilliseconds(milliseconds), start.PlusMilliseconds(milliseconds));
            Assert.AreEqual(start + Duration.FromMilliseconds(-milliseconds), start.PlusMilliseconds(-milliseconds));

            Assert.AreEqual(start + Duration.FromTicks(ticks), start.PlusTicks(ticks));
            Assert.AreEqual(start + Duration.FromTicks(-ticks), start.PlusTicks(-ticks));

            Assert.AreEqual(start + Duration.FromNanoseconds(nanoseconds), start.PlusNanoseconds(nanoseconds));
            Assert.AreEqual(start + Duration.FromNanoseconds(-nanoseconds), start.PlusNanoseconds(-nanoseconds));
        }
コード例 #27
0
 public LocalDateTime ComputeStartTime(LocalDateTime referenceTime)
 {
     return(referenceTime.Plus(this._deduplicationPeriodDuration));
 }
コード例 #28
0
ファイル: TimeInterval.cs プロジェクト: ericveilleux/Corazon
 public TimeInterval(LocalDateTime from, Period period)
     : this(from, from.Plus(period))
 {
 }