Пример #1
0
        public void ExpandStartToTest()
        {
            TimeRange timeRange = new TimeRange(start, end);

            timeRange.ExpandStartTo(start.AddMilliseconds(1));
            Assert.Equal(timeRange.Start, start);
            timeRange.ExpandStartTo(start.AddMinutes(-1));
            Assert.Equal(timeRange.Start, start.AddMinutes(-1));
        }         // ExpandStartToTest
Пример #2
0
        public void ExpandStartToTest()
        {
            var timeRange = new TimeRange(_start, _end);

            timeRange.ExpandStartTo(_start.AddMilliseconds(1));
            timeRange.Start.Should().Be(_start);

            timeRange.ExpandStartTo(_start.AddMinutes(-1));
            timeRange.Start.Should().Be(_start.AddMinutes(-1));
        }
Пример #3
0
        /// <summary>
        /// The GetMatchingDirectoryNames
        /// </summary>
        /// <param name="startDate">The startDate<see cref="DateTime"/></param>
        /// <param name="endDate">The endDate<see cref="DateTime"/></param>
        /// <param name="listTwo">The listTwo<see cref="List{DateTime}"/></param>
        /// <returns>The <see cref="List{DateTime}"/></returns>
        public List <DateTime> GetMatchingDirectoryNames(DateTime startDate, DateTime endDate, List <DateTime> listTwo)
        {
            TimeRange selectedTimeRange = new TimeRange(startDate, endDate, false);

            List <DateTime> returnList = new List <DateTime>();

            if (startDate.Date == endDate.Date)
            {
                startDate = startDate.AddHours(-1);
                endDate   = endDate.AddDays(1);
            }

            foreach (DateTime dateTimeObject in listTwo)
            {
                TimeRange datesFromDirectory = new TimeRange(dateTimeObject, false);

                selectedTimeRange.ExpandStartTo(startDate);
                selectedTimeRange.ExpandEndTo(endDate);

                if (datesFromDirectory.IntersectsWith(selectedTimeRange))
                {
                    returnList.Add(dateTimeObject);
                }
            }

            return(returnList);
        }
Пример #4
0
        public static void TestTimeRange2()
        {
            var timeRange = new TimeRange(new DateTime(2018, 11, 22, 10, 15, 00), Duration.Minutes(30));

            timeRange.ExpandStartTo(new DateTime(2018, 11, 22, 10, 14, 00));

            Console.WriteLine($"Result: {timeRange}");
        }
Пример #5
0
        public void ExpandStartToTest() {
            var timeRange = new TimeRange(_start, _end);

            timeRange.ExpandStartTo(_start.AddMilliseconds(1));
            timeRange.Start.Should().Be(_start);

            timeRange.ExpandStartTo(_start.AddMinutes(-1));
            timeRange.Start.Should().Be(_start.AddMinutes(-1));
        }