示例#1
0
        public void NextDayOfTheWeek_NextWeekdateIncludeCurrentDay()
        {
            var output = RockFilters.NextDayOfTheWeek("2018-5-1 3:00 PM", "Tuesday", true);

            DateTimeAssert.AreEqual(output, DateTime.Parse("2018-5-1 3:00 PM"));

            output = RockFilters.NextDayOfTheWeek("2018-5-1 3:00 PM", "Wednesday", true);
            DateTimeAssert.AreEqual(output, DateTime.Parse("2018-5-2 3:00 PM"));

            output = RockFilters.NextDayOfTheWeek("2018-5-1 3:00 PM", "Monday", true);
            DateTimeAssert.AreEqual(output, DateTime.Parse("2018-5-7 3:00 PM"));
        }
示例#2
0
        public void NextDayOfTheWeek_NextWeekdateTwoWeeks()
        {
            // Since we're not including the current day, we advance to next two week's out to Tuesday, 5/15
            var output = RockFilters.NextDayOfTheWeek("2018-5-1 3:00 PM", "Tuesday", false, 2);

            DateTimeAssert.AreEqual(output, DateTime.Parse("2018-5-15 3:00 PM"));

            // Since Wednesday has not happened, we advance two Wednesdays -- which is Wed, 5/9
            output = RockFilters.NextDayOfTheWeek("2018-5-1 3:00 PM", "Wednesday", false, 2);
            DateTimeAssert.AreEqual(output, DateTime.Parse("2018-5-9 3:00 PM"));

            // Since Monday has passed, we advance to two week's out Monday, 5/14
            output = RockFilters.NextDayOfTheWeek("2018-5-1 3:00 PM", "Monday", false, 2);
            DateTimeAssert.AreEqual(output, DateTime.Parse("2018-5-14 3:00 PM"));
        }
示例#3
0
        public void NextDayOfTheWeek_NextWeekdate()
        {
            // Since we're not including the current day, we advance to next week's Tuesday, 5/8
            var output = RockFilters.NextDayOfTheWeek("2018-5-1 3:00 PM", "Tuesday");

            DateTimeAssert.AreEqual(output, DateTime.Parse("2018-5-8 3:00 PM"));

            // Since Wednesday has not happened, we advance to it -- which is Wed, 5/2
            output = RockFilters.NextDayOfTheWeek("2018-5-1 3:00 PM", "Wednesday");
            DateTimeAssert.AreEqual(output, DateTime.Parse("2018-5-2 3:00 PM"));

            // Since Monday has passed, we advance to next week's Monday, 5/7
            output = RockFilters.NextDayOfTheWeek("2018-5-1 3:00 PM", "Monday");
            DateTimeAssert.AreEqual(output, DateTime.Parse("2018-5-7 3:00 PM"));

            // From the Lava documentation
            output = RockFilters.NextDayOfTheWeek("2011-2-9 3:00 PM", "Friday");
            DateTimeAssert.AreEqual(output, DateTime.Parse("2011-2-11 3:00 PM"));
        }
示例#4
0
        public void NextDayOfTheWeek_NextWeekdateBackOneWeek()
        {
            // In this case, since it's Tuesday (and we're not including current day), then
            // the current day counts as the *previous* week's Tuesday.
            var output = RockFilters.NextDayOfTheWeek("2018-5-1 3:00 PM", "Tuesday", false, -1);

            DateTimeAssert.AreEqual(output, DateTime.Parse("2018-5-1 3:00 PM"));

            // If we include the current day (so it counts as *this* week), then one week ago would be
            // last Tuesday, April 24.
            output = RockFilters.NextDayOfTheWeek("2018-5-1 3:00 PM", "Tuesday", true, -1);
            DateTimeAssert.AreEqual(output, DateTime.Parse("2018-4-24 3:00 PM"));

            // Get previous week's Wednesday, 4/25
            output = RockFilters.NextDayOfTheWeek("2018-5-1 3:00 PM", "Wednesday", false, -1);
            DateTimeAssert.AreEqual(output, DateTime.Parse("2018-4-25 3:00 PM"));

            // Since Monday has just passed, we get this past Monday, 4/30
            output = RockFilters.NextDayOfTheWeek("2018-5-1 3:00 PM", "Monday", false, -1);
            DateTimeAssert.AreEqual(output, DateTime.Parse("2018-4-30 3:00 PM"));
        }
示例#5
0
        public void ToMidnight_DateTime()
        {
            var output = RockFilters.ToMidnight(RockDateTime.Now);

            DateTimeAssert.AreEqual(output, RockDateTime.Now.Date);
        }
示例#6
0
        public void NextDayOfTheWeek_NextWeekdateBackOneWeek()
        {
            var output = RockFilters.NextDayOfTheWeek("5/1/2018 3:00 PM", "Tuesday", false, -1);

            DateTimeAssert.AreEqual(output, DateTime.Parse("4/24/2018 3:00 PM"));
        }
示例#7
0
        public void ToMidnight_TextString()
        {
            var output = RockFilters.ToMidnight("5/1/2018 3:00 PM");

            DateTimeAssert.AreEqual(output, DateTime.Parse("5/1/2018 12:00 AM"));
        }
示例#8
0
        public void DateAdd_AddWeeksIntervalToGivenDate()
        {
            var output = RockFilters.DateAdd("5/1/2018 3:00 PM", 2, "w");

            DateTimeAssert.AreEqual(output, DateTime.Parse("5/15/2018 3:00 PM"));
        }
示例#9
0
        public void NextDayOfTheWeek_NextWeekdate()
        {
            var output = RockFilters.NextDayOfTheWeek("5/1/2018 3:00 PM", "Tuesday");

            DateTimeAssert.AreEqual(output, DateTime.Parse("5/8/2018 3:00 PM"));
        }
示例#10
0
        public void DateAdd_AddYearsIntervalToGivenLeapDate()
        {
            var output = RockFilters.DateAdd("2/29/2016 3:00 PM", 1, "y");

            DateTimeAssert.AreEqual(output, DateTime.Parse("2/28/2017 3:00 PM"));
        }
示例#11
0
        public void DateAdd_AddMonthsIntervalToGivenLongerMonthDate()
        {
            var output = RockFilters.DateAdd("5/31/2018 3:00 PM", 1, "M");

            DateTimeAssert.AreEqual(output, DateTime.Parse("6/30/2018 3:00 PM"));
        }
示例#12
0
        public void DateAdd_AddSecondsIntervalToGivenDate()
        {
            var output = RockFilters.DateAdd("5/1/2018 3:00 PM", 300, "s");

            DateTimeAssert.AreEqual(output, DateTime.Parse("5/1/2018 3:05 PM"));
        }
示例#13
0
        public void DateAdd_AddMinutesIntervalToGivenDate()
        {
            var output = RockFilters.DateAdd("5/1/2018 3:00 PM", 120, "m");

            DateTimeAssert.AreEqual(output, DateTime.Parse("5/1/2018 5:00 PM"));
        }
示例#14
0
        public void DateAdd_AddHoursIntervalToGivenDate()
        {
            var output = RockFilters.DateAdd("5/1/2018 3:00 PM", 1, "h");

            DateTimeAssert.AreEqual(output, DateTime.Parse("5/1/2018 4:00 PM"));
        }
示例#15
0
        public void DateAdd_AddDaysIntervalToGivenDate()
        {
            var output = RockFilters.DateAdd("5/1/2018", 3, "d");

            DateTimeAssert.AreEqual(output, DateTime.Parse("5/4/2018"));
        }
示例#16
0
        public void DateAdd_AddDaysDefaultViaNow()
        {
            var output = RockFilters.DateAdd("Now", 5);

            DateTimeAssert.AreEqual(output, RockDateTime.Now.AddDays(5));
        }