AddDays() публичный Метод

public AddDays ( int days ) : Day
days int
Результат Day
        // ----------------------------------------------------------------------
        protected override bool OnVisitDay( Day day, CalendarPeriodCollectorContext context )
        {
            // allow only the last day of the month
            if ( day.Month == day.AddDays( TimeSpec.DaysPerWeek ).Month )
            {
                return false;
            }

            return base.OnVisitDay( day, context );
        }
Пример #2
0
        public void AddDaysTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            DateTime nowDay = new DateTime( now.Year, now.Month, now.Day );
            Day day = new Day( now, TimeCalendar.NewEmptyOffset() );

            Assert.AreEqual( day.AddDays( 0 ), day );

            DateTime previousDay = nowDay.AddDays( -1 );
            Assert.AreEqual( day.AddDays( -1 ).Year, previousDay.Year );
            Assert.AreEqual( day.AddDays( -1 ).Month, previousDay.Month );
            Assert.AreEqual( day.AddDays( -1 ).DayValue, previousDay.Day );

            DateTime nextDay = nowDay.AddDays( 1 );
            Assert.AreEqual( day.AddDays( 1 ).Year, nextDay.Year );
            Assert.AreEqual( day.AddDays( 1 ).Month, nextDay.Month );
            Assert.AreEqual( day.AddDays( 1 ).DayValue, nextDay.Day );
        }
Пример #3
0
 public void GetPreviousDayTest()
 {
     Day day = new Day();
     Assert.AreEqual( day.GetPreviousDay(), day.AddDays( -1 ) );
 }
Пример #4
0
 public void GetNextDayTest()
 {
     Day day = new Day();
     Assert.AreEqual( day.GetNextDay(), day.AddDays( 1 ) );
 }
Пример #5
0
        public void SimpleBackwardTest()
        {
            Day start = new Day( new DateTime( 2011, 2, 15 ) );

            DaySeeker daySeeker = new DaySeeker( SeekDirection.Backward );
            Day day1 = daySeeker.FindDay( start, 0 );
            Assert.IsTrue( day1.IsSamePeriod( start ) );

            Day day2 = daySeeker.FindDay( start, 1 );
            Assert.IsTrue( day2.IsSamePeriod( start.GetPreviousDay() ) );

            Day day3 = daySeeker.FindDay( start, 100 );
            Assert.IsTrue( day3.IsSamePeriod( start.AddDays( -100 ) ) );
        }
Пример #6
0
        public void SimpleForwardTest()
        {
            Day start = new Day( new DateTime( 2011, 2, 15 ) );

            DaySeeker daySeeker = new DaySeeker();
            Day day1 = daySeeker.FindDay( start, 0 );
            Assert.IsTrue( day1.IsSamePeriod( start ) );

            Day day2 = daySeeker.FindDay( start, 1 );
            Assert.IsTrue( day2.IsSamePeriod( start.GetNextDay() ) );

            Day day3 = daySeeker.FindDay( start, 100 );
            Assert.IsTrue( day3.IsSamePeriod( start.AddDays( 100 ) ) );
        }
Пример #7
0
        // ----------------------------------------------------------------------
        private void SelectPeriod( PeriodSelectType periodSelectType )
        {
            int offset = 0;
            switch ( periodSelectType )
            {
                case PeriodSelectType.Previous:
                    offset = -1;
                    break;
                case PeriodSelectType.Current:
                    ResetWorkingPeriod();
                    return;
                case PeriodSelectType.Next:
                    offset = 1;
                    break;
            }

            switch ( WorkingTimePeriod )
            {
                case TimePeriodMode.Year:
                    Year year = new Year( WorkingPeriodStartDate );
                    SetWorkingPeriod( year.AddYears( offset ) );
                    break;
                case TimePeriodMode.Halfyear:
                    Halfyear halfyear = new Halfyear( WorkingPeriodStartDate );
                    SetWorkingPeriod( halfyear.AddHalfyears( offset ) );
                    break;
                case TimePeriodMode.Quarter:
                    Quarter quarter = new Quarter( WorkingPeriodStartDate );
                    SetWorkingPeriod( quarter.AddQuarters( offset ) );
                    break;
                case TimePeriodMode.Month:
                    Month month = new Month( WorkingPeriodStartDate );
                    SetWorkingPeriod( month.AddMonths( offset ) );
                    break;
                case TimePeriodMode.Week:
                    Week week = new Week( WorkingPeriodStartDate );
                    SetWorkingPeriod( week.AddWeeks( offset ) );
                    break;
                case TimePeriodMode.Day:
                    Day day = new Day( WorkingPeriodStartDate );
                    SetWorkingPeriod( day.AddDays( offset ) );
                    break;
            }
        }