Пример #1
0
        public void DataTypes_DateHelpers_dateOfNextDay_today()
        {
            var day  = DayOfWeek.Thursday;
            var date = new System.DateTime(2017, 9, 28);

            Assert.IsFalse(TimexDateHelpers.DatePartEquals(TimexDateHelpers.DateOfNextDay(day, date), date));
        }
        public static DateTime GetDateTime(this string timex)
        {
            var timexProperty = new TimexProperty(timex);
            var today         = DateTime.Today;

            var year   = timexProperty.Year ?? today.Year;
            var month  = timexProperty.Month ?? today.Month;
            var day    = timexProperty.DayOfMonth ?? today.Day;
            var hour   = timexProperty.Hour ?? 0;
            var minute = timexProperty.Minute ?? 0;

            DateTime result;

            if (timexProperty.DayOfWeek.HasValue)
            {
                result = TimexDateHelpers.DateOfNextDay((DayOfWeek)timexProperty.DayOfWeek.Value, today);
                result = result.AddHours(hour);
                result = result.AddMinutes(minute);
            }
            else
            {
                result = new DateTime(year, month, day, hour, minute, 0);
                if (result < today)
                {
                    result = result.AddYears(1);
                }
            }

            return(result);
        }
Пример #3
0
        public void DataTypes_DateHelpers_dateOfNextDay_Wednesday_next_week()
        {
            var day  = DayOfWeek.Wednesday;
            var date = new System.DateTime(2017, 9, 28);

            Assert.IsTrue(TimexDateHelpers.DatePartEquals(TimexDateHelpers.DateOfNextDay(day, date), new System.DateTime(2017, 10, 4)));
        }
Пример #4
0
        public void DataTypes_Creator_nextWeek()
        {
            var start = TimexDateHelpers.DateOfNextDay(DayOfWeek.Monday, System.DateTime.Now);
            var t     = TimexProperty.FromDate(start);

            t.Days = 7;
            var expected = t.TimexValue;

            Assert.AreEqual(expected, TimexCreator.NextWeek());
        }