상속: DayTimeRange
        // ----------------------------------------------------------------------
        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 DaySeekerContext( Day startDay, int dayCount )
 {
     if ( startDay == null )
     {
         throw new ArgumentNullException( "startDay" );
     }
     StartDay = startDay;
     DayCount = Math.Abs( dayCount );
     RemaingDays = DayCount;
 }
예제 #3
0
 // ----------------------------------------------------------------------
 public static void ShowDay( Day day, string caption = "Day" )
 {
     WriteLine( "{0}: {1}", caption, day );
     WriteIndentLine( "Year: {0}", day.Year );
     WriteIndentLine( "Month: {0}", day.Month );
     WriteIndentLine( "DayValue: {0}", day.DayValue );
     WriteIndentLine( "DayOfWeek: {0}", day.DayOfWeek );
     WriteIndentLine( "DayName: {0}", day.DayName );
     WriteIndentLine( "FirstHourStart: {0}", day.FirstHourStart );
     WriteIndentLine( "LastHourStart: {0}", day.LastHourStart );
     WriteLine();
 }
예제 #4
0
        // ----------------------------------------------------------------------
        public void ProcessDay( Day day )
        {
            if ( IsFinished )
            {
                return;
            }

            RemaingDays -= 1;
            if ( IsFinished )
            {
                FoundDay = day;
            }
        }
예제 #5
0
        public void SeekDirectionTest()
        {
            Day start = new Day( new DateTime( 2011, 2, 15 ) );

            DaySeeker forwardSeeker = new DaySeeker();
            Day day1 = forwardSeeker.FindDay( start, 1 );
            Assert.IsTrue( day1.IsSamePeriod( start.GetNextDay() ) );
            Day day2 = forwardSeeker.FindDay( start, -1 );
            Assert.IsTrue( day2.IsSamePeriod( start.GetPreviousDay() ) );

            DaySeeker backwardSeeker = new DaySeeker( SeekDirection.Backward );
            Day day3 = backwardSeeker.FindDay( start, 1 );
            Assert.IsTrue( day3.IsSamePeriod( start.GetPreviousDay() ) );
            Day day4 = backwardSeeker.FindDay( start, -1 );
            Assert.IsTrue( day4.IsSamePeriod( start.GetNextDay() ) );
        }
예제 #6
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 );
        }
예제 #7
0
        public void SeekWeekendHolidayTest()
        {
            Day start = new Day( new DateTime( 2011, 2, 15 ) );

            CalendarVisitorFilter filter = new CalendarVisitorFilter();
            filter.AddWorkingWeekDays();
            filter.ExcludePeriods.Add( new Days( 2011, 2, 28, 14 ) );  // 14 days -> week 9 and 10

            DaySeeker daySeeker = new DaySeeker( filter );

            Day day1 = daySeeker.FindDay( start, 3 ); // wtihtin the same working week
            Assert.IsTrue( day1.IsSamePeriod( new Day( 2011, 2, 18 ) ) );

            Day day2 = daySeeker.FindDay( start, 4 ); // saturday -> next monday
            Assert.IsTrue( day2.IsSamePeriod( new Day( 2011, 2, 21 ) ) );

            Day day3 = daySeeker.FindDay( start, 10 ); // holidays -> next monday
            Assert.IsTrue( day3.IsSamePeriod( new Day( 2011, 3, 15 ) ) );
        }
예제 #8
0
        // ----------------------------------------------------------------------
        public static void ShowAll( int periodCount, int year, YearMonth yearMonth, int dayValue )
        {
            WriteLine( "Input: count={0}, year={1}, month={2}, day={3}", periodCount, year, yearMonth, dayValue );
            WriteLine();

            DayTimeRange dayTimeRange;
            if ( periodCount == 1 )
            {
                Day day = new Day( year, (int)yearMonth, dayValue );
                dayTimeRange = day;

                Day previousDay = day.GetPreviousDay();
                Day nextDay = day.GetNextDay();

                ShowDay( day );
                ShowCompactDay( previousDay, "Previous Day" );
                ShowCompactDay( nextDay, "Next Day" );
                WriteLine();
            }
            else
            {
                Days days = new Days( year, (int)yearMonth, dayValue, periodCount );
                dayTimeRange = days;

                ShowDays( days );
                WriteLine();

                foreach ( Day day in days.GetDays() )
                {
                    ShowCompactDay( day );
                }
                WriteLine();
            }

            foreach ( Hour hour in dayTimeRange.GetHours() )
            {
                HourDemo.ShowCompactHour( hour );
            }
            WriteLine();
        }
예제 #9
0
        public void InitValuesTest()
        {
            DateTime now = ClockProxy.Clock.Now;
            DateTime firstDay = new DateTime( now.Year, now.Month, now.Day );
            DateTime secondDay = firstDay.AddDays( 1 );
            Day day = new Day( now, TimeCalendar.NewEmptyOffset() );

            Assert.AreEqual( day.Start.Year, firstDay.Year );
            Assert.AreEqual( day.Start.Month, firstDay.Month );
            Assert.AreEqual( day.Start.Day, firstDay.Day );
            Assert.AreEqual( day.Start.Hour, 0 );
            Assert.AreEqual( day.Start.Minute, 0 );
            Assert.AreEqual( day.Start.Second, 0 );
            Assert.AreEqual( day.Start.Millisecond, 0 );

            Assert.AreEqual( day.End.Year, secondDay.Year );
            Assert.AreEqual( day.End.Month, secondDay.Month );
            Assert.AreEqual( day.End.Day, secondDay.Day );
            Assert.AreEqual( day.End.Hour, 0 );
            Assert.AreEqual( day.End.Minute, 0 );
            Assert.AreEqual( day.End.Second, 0 );
            Assert.AreEqual( day.End.Millisecond, 0 );
        }
예제 #10
0
 public void GetPreviousDayTest()
 {
     Day day = new Day();
     Assert.AreEqual( day.GetPreviousDay(), day.AddDays( -1 ) );
 }
예제 #11
0
 public void GetNextDayTest()
 {
     Day day = new Day();
     Assert.AreEqual( day.GetNextDay(), day.AddDays( 1 ) );
 }
예제 #12
0
        // ----------------------------------------------------------------------
        public TimeSpan CalcWorkingPeriod( DateTime start, DateTime end,
            ITimePeriodCollection excludePeriods = null)
        {
            if ( start.Equals( end ) )
            {
                return TimeSpan.Zero;
            }

            // test range
            TimeRange testRange = new TimeRange( start, end );

            // search range
            DateTime searchStart = new Day( testRange.Start ).Start;
            DateTime serachEnd = new Day( testRange.End ).GetNextDay().Start;
            TimeRange searchPeriod = new TimeRange( searchStart, serachEnd );

            // search filter
            CalendarPeriodCollectorFilter filter = new CalendarPeriodCollectorFilter();
            filter.AddWorkingWeekDays(); // working days
            if ( excludePeriods != null )
            {
                filter.ExcludePeriods.AddAll( excludePeriods );
            }
            filter.CollectingHours.Add( new HourRange( 07, 12 ) ); // working hours
            filter.CollectingHours.Add( new HourRange( 13, 19 ) ); // working hours

            // collect working hours
            TimeCalendar calendar = new TimeCalendar( new TimeCalendarConfig { EndOffset = TimeSpan.Zero } );
            CalendarPeriodCollector collector = new CalendarPeriodCollector( filter, searchPeriod, SeekDirection.Forward, calendar );
            collector.CollectHours();

            TimeSpan workingPeriod = new TimeSpan();
            foreach ( ICalendarTimeRange period in collector.Periods )
            {
                // get the intersection of the test-range and the day working-hours
                ITimePeriod intersection = testRange.GetIntersection( period );
                if ( intersection == null )
                {
                    continue;
                }
                workingPeriod = workingPeriod.Add( intersection.Duration );
            }
            return workingPeriod;
        }
예제 #13
0
        // ----------------------------------------------------------------------
        public double NetworkDays( DateTime start, DateTime end, IEnumerable<DateTime> holidays = null, ITimePeriodCollection holidayPeriods = null )
        {
            Day startDay = new Day( start < end ? start : end );
            Day endDay = new Day( end > start ? end : start );
            if ( startDay.Equals( endDay ) )
            {
                return 0;
            }

            CalendarPeriodCollectorFilter filter = new CalendarPeriodCollectorFilter();
            filter.AddWorkingWeekDays(); // only working days
            if ( holidays != null )
            {
                foreach ( DateTime holiday in holidays )
                {
                    filter.ExcludePeriods.Add( new Day( holiday ) );
                }
            }
            if ( holidayPeriods != null )
            {
                filter.ExcludePeriods.AddAll( holidayPeriods );
            }

            CalendarTimeRange testPeriod = new CalendarTimeRange( start, end );
            CalendarPeriodCollector collector = new CalendarPeriodCollector( filter, testPeriod );
            collector.CollectDays();

            double networkDays = 0.0;
            foreach ( ICalendarTimeRange period in collector.Periods )
            {
                networkDays += Math.Round( period.Duration.TotalDays, 2 );
            }
            return networkDays;
        }
예제 #14
0
 // ----------------------------------------------------------------------
 private void UpdateSelectedPeriodInfo()
 {
     TimeCalendar timeCalendar = TimeCalendar.New( SelectedYearBaseMonth );
     switch ( SelectedPeriodMode )
     {
         case TimePeriodMode.Year:
             Year year = new Year( WorkingDate, timeCalendar );
             periodInfo.Clear();
             periodInfo.AddItem( "Year", year );
             periodInfo.AddItem( "YearBaseMonth", year.YearBaseMonth );
             periodInfo.AddItem( "IsCalendarYear", year.IsCalendarYear );
             periodInfo.AddItem( "StartYear", year.StartYear );
             periodInfo.AddItem( "FirstDayStart", year.FirstDayStart );
             periodInfo.AddItem( "LastDayStart", year.LastDayStart );
             periodInfo.AddItem( "LastMonthStart", year.LastMonthStart );
             periodInfo.AddItem( "YearName", year.YearName );
             periodInfo.AddSection( "Previous/Next" );
             periodInfo.AddItem( "Previous", year.GetPreviousYear() );
             periodInfo.AddItem( "Next", year.GetNextYear() );
             periodInfo.AddSubitems( "Halfyears", year.GetHalfyears() );
             periodInfo.AddSubitems( "Quarters", year.GetQuarters() );
             periodInfo.AddSubitems( "Months", year.GetMonths() );
             SelectedPeriodInfo = periodInfo.ToString();
             break;
         case TimePeriodMode.Halfyear:
             Halfyear halfyear = new Halfyear( WorkingDate, timeCalendar );
             periodInfo.Clear();
             periodInfo.AddItem( "Halfyear", halfyear );
             periodInfo.AddItem( "YearBaseMonth", halfyear.YearBaseMonth );
             periodInfo.AddItem( "StartMonth", halfyear.StartMonth );
             periodInfo.AddItem( "Year", halfyear.Year );
             periodInfo.AddItem( "YearHalfyear", halfyear.YearHalfyear );
             periodInfo.AddItem( "IsCalendarHalfyear", halfyear.IsCalendarHalfyear );
             periodInfo.AddItem( "MultipleCalendarYears", halfyear.MultipleCalendarYears );
             periodInfo.AddItem( "HalfyearName", halfyear.HalfyearName );
             periodInfo.AddItem( "HalfyearOfYearName", halfyear.HalfyearOfYearName );
             periodInfo.AddItem( "LastDayStart", halfyear.LastDayStart );
             periodInfo.AddItem( "LastMonthStart", halfyear.LastMonthStart );
             periodInfo.AddSection( "Previous/Next" );
             periodInfo.AddItem( "Previousr", halfyear.GetPreviousHalfyear() );
             periodInfo.AddItem( "Next", halfyear.GetNextHalfyear() );
             periodInfo.AddSubitems( "Quarters", halfyear.GetQuarters() );
             periodInfo.AddSubitems( "Months", halfyear.GetMonths() );
             SelectedPeriodInfo = periodInfo.ToString();
             break;
         case TimePeriodMode.Quarter:
             Quarter quarter = new Quarter( WorkingDate, timeCalendar );
             periodInfo.Clear();
             periodInfo.AddItem( "Quarter", quarter );
             periodInfo.AddItem( "YearBaseMonth", quarter.YearBaseMonth );
             periodInfo.AddItem( "StartMonth", quarter.StartMonth );
             periodInfo.AddItem( "Year", quarter.Year );
             periodInfo.AddItem( "YearQuarter", quarter.YearQuarter );
             periodInfo.AddItem( "IsCalendarQuarter", quarter.IsCalendarQuarter );
             periodInfo.AddItem( "MultipleCalendarYears", quarter.MultipleCalendarYears );
             periodInfo.AddItem( "QuarterName", quarter.QuarterName );
             periodInfo.AddItem( "QuarterOfYearName", quarter.QuarterOfYearName );
             periodInfo.AddItem( "LastDayStart", quarter.FirstDayStart );
             periodInfo.AddItem( "LastMonthStart", quarter.LastDayStart );
             periodInfo.AddSection( "Previous/Next" );
             periodInfo.AddItem( "Previous", quarter.GetPreviousQuarter() );
             periodInfo.AddItem( "Next", quarter.GetNextQuarter() );
             periodInfo.AddSubitems( "Months", quarter.GetMonths() );
             SelectedPeriodInfo = periodInfo.ToString();
             break;
         case TimePeriodMode.Month:
             Month month = new Month( WorkingDate, timeCalendar );
             periodInfo.Clear();
             periodInfo.AddItem( "Month", month );
             periodInfo.AddItem( "YearBaseMonth", month.YearMonth );
             periodInfo.AddItem( "Year", month.Year );
             periodInfo.AddItem( "DaysInMonth", month.DaysInMonth );
             periodInfo.AddItem( "MonthName", month.MonthName );
             periodInfo.AddItem( "MonthOfYearName", month.MonthOfYearName );
             periodInfo.AddItem( "LastDayStart", month.FirstDayStart );
             periodInfo.AddItem( "LastMonthStart", month.LastDayStart );
             periodInfo.AddSection( "Previous/Next" );
             periodInfo.AddItem( "Previous", month.GetPreviousMonth() );
             periodInfo.AddItem( "Next", month.GetNextMonth() );
             periodInfo.AddSubitems( "Days", month.GetDays() );
             SelectedPeriodInfo = periodInfo.ToString();
             break;
         case TimePeriodMode.Week:
             Week week = new Week( WorkingDate, timeCalendar );
             periodInfo.Clear();
             periodInfo.AddItem( "Week", week );
             periodInfo.AddItem( "MultipleCalendarYears", week.MultipleCalendarYears );
             periodInfo.AddItem( "FirstDayStart", week.FirstDayStart );
             periodInfo.AddItem( "FirstDayOfWeek", week.FirstDayOfWeek );
             periodInfo.AddItem( "LastDayStart", week.LastDayStart );
             periodInfo.AddItem( "LastDayOfWeek", week.LastDayOfWeek );
             periodInfo.AddItem( "WeekOfYear", week.WeekOfYear );
             periodInfo.AddItem( "WeekOfYearName", week.WeekOfYearName );
             periodInfo.AddSection( "Previous/Next" );
             periodInfo.AddItem( "Previous", week.GetPreviousWeek() );
             periodInfo.AddItem( "Next", week.GetNextWeek() );
             periodInfo.AddSubitems( "Days", week.GetDays() );
             SelectedPeriodInfo = periodInfo.ToString();
             break;
         case TimePeriodMode.Day:
             Day day = new Day( WorkingDate, timeCalendar );
             periodInfo.Clear();
             periodInfo.AddItem( "Day", day );
             periodInfo.AddItem( "Year", day.Year );
             periodInfo.AddItem( "FirstDayStart", day.FirstDayStart );
             periodInfo.AddItem( "Month", day.Month );
             periodInfo.AddItem( "DayValue", day.DayValue );
             periodInfo.AddItem( "DayOfWeek", day.DayOfWeek );
             periodInfo.AddItem( "DayName", day.DayName );
             periodInfo.AddItem( "FirstHourStart", day.FirstHourStart );
             periodInfo.AddItem( "LastHourStart", day.LastHourStart );
             periodInfo.AddSection( "Previous/Next" );
             periodInfo.AddItem( "Previous", day.GetPreviousDay() );
             periodInfo.AddItem( "Next", day.GetNextDay() );
             periodInfo.AddSubitems( "Hours", day.GetHours() );
             SelectedPeriodInfo = periodInfo.ToString();
             break;
         case TimePeriodMode.Hour:
             Hour hour = new Hour( WorkingDate, timeCalendar );
             periodInfo.Clear();
             periodInfo.AddItem( "Hour", hour );
             periodInfo.AddItem( "Year", hour.Year );
             periodInfo.AddItem( "Month", hour.Month );
             periodInfo.AddItem( "Day", hour.Day );
             periodInfo.AddItem( "HourValue", hour.HourValue );
             periodInfo.AddItem( "FirstMinuteStart", hour.FirstMinuteStart );
             periodInfo.AddItem( "LastMinuteStart", hour.LastMinuteStart );
             periodInfo.AddSection( "Previous/Next" );
             periodInfo.AddItem( "Previous", hour.GetPreviousHour() );
             periodInfo.AddItem( "Next", hour.GetNextHour() );
             periodInfo.AddSubitems( "Minutes", hour.GetMinutes() );
             SelectedPeriodInfo = periodInfo.ToString();
             break;
         case TimePeriodMode.Minute:
             Minute minute = new Minute( WorkingDate, timeCalendar );
             periodInfo.Clear();
             periodInfo.AddItem( "Minute", minute );
             periodInfo.AddItem( "Year", minute.Year );
             periodInfo.AddItem( "Month", minute.Month );
             periodInfo.AddItem( "Day", minute.Day );
             periodInfo.AddItem( "Hour", minute.Hour );
             periodInfo.AddItem( "MinuteValue", minute.MinuteValue );
             periodInfo.AddSection( "Previous/Next" );
             periodInfo.AddItem( "Previous", minute.GetPreviousMinute() );
             periodInfo.AddItem( "Next", minute.GetNextMinute() );
             SelectedPeriodInfo = periodInfo.ToString();
             break;
     }
 }
예제 #15
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 ) ) );
        }
예제 #16
0
        public void DefaultCalendarTest()
        {
            DateTime yearStart = new DateTime( ClockProxy.Clock.Now.Year, 1, 1 );
            foreach ( YearMonth yearMonth in Enum.GetValues( typeof( YearMonth ) ) )
            {
                DateTime monthStart = new DateTime( yearStart.Year, (int)yearMonth, 1 );
                DateTime monthEnd = monthStart.AddMonths( 1 ).AddDays( -1 );

                for ( int monthDay = monthStart.Day; monthDay < monthEnd.Day; monthDay++ )
                {
                    Day day = new Day( monthStart.AddDays( monthDay - 1 ) );
                    Assert.AreEqual( day.Year, yearStart.Year );
                    Assert.AreEqual( day.Month, monthStart.Month );
                    Assert.AreEqual( day.Month, monthEnd.Month );
                    Assert.AreEqual( day.DayValue, monthDay );
                    Assert.AreEqual( day.Start, monthStart.AddDays( monthDay - 1 ).Add( day.Calendar.StartOffset ) );
                    Assert.AreEqual( day.End, monthStart.AddDays( monthDay ).Add( day.Calendar.EndOffset ) );
                }
            }
        }
예제 #17
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 ) ) );
        }
예제 #18
0
        public void DaySeekerSample()
        {
            Day start = new Day( new DateTime( 2011, 2, 15 ) );
            Console.WriteLine( "DaySeeker Start: " + start );
            // > DaySeeker Start: Dienstag; 15.02.2011 | 0.23:59

            CalendarVisitorFilter filter = new CalendarVisitorFilter();
            filter.AddWorkingWeekDays(); // only working days
            filter.ExcludePeriods.Add( new Week( 2011, 9 ) );  // week #9
            Console.WriteLine( "DaySeeker Holidays: " + filter.ExcludePeriods[ 0 ] );
            // > DaySeeker Holidays: w/c 9 2011; 28.02.2011 - 06.03.2011 | 6.23:59

            DaySeeker daySeeker = new DaySeeker( filter );
            Day day1 = daySeeker.FindDay( start, 3 ); // same working week
            Console.WriteLine( "DaySeeker(3): " + day1 );
            // > DaySeeker(3): Freitag; 18.02.2011 | 0.23:59

            Day day2 = daySeeker.FindDay( start, 4 ); // Saturday -> next Monday
            Console.WriteLine( "DaySeeker(4): " + day2 );
            // > DaySeeker(4): Montag; 21.02.2011 | 0.23:59

            Day day3 = daySeeker.FindDay( start, 9 ); // Holidays -> next Monday
            Console.WriteLine( "DaySeeker(9): " + day3 );
            // > DaySeeker(9): Montag; 07.03.2011 | 0.23:59
        }
예제 #19
0
 // ----------------------------------------------------------------------
 public static void ShowCompactDay( Day day, string caption = "Day" )
 {
     WriteLine( "{0}: {1}", caption, day );
 }
예제 #20
0
        public void GetHoursTest()
        {
            Day day = new Day();

            ITimePeriodCollection hours = day.GetHours();
            Assert.AreNotEqual( hours, null );

            int index = 0;
            foreach ( Hour hour in hours )
            {
                Assert.AreEqual( hour.Start, day.Start.AddHours( index ) );
                Assert.AreEqual( hour.End, hour.Calendar.MapEnd( hour.Start.AddHours( 1 ) ) );
                index++;
            }
            Assert.AreEqual( index, TimeSpec.HoursPerDay );
        }
예제 #21
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;
            }
        }