Inheritance: ICalendarVisitorFilter
Example #1
0
        // ----------------------------------------------------------------------
        public DateTime AddBusinessDays1( DateTime startDate, int noOfBusinessDays )
        {
            CalendarVisitorFilter filter = new CalendarVisitorFilter();
            filter.AddWorkingWeekDays();

            DaySeeker seeker = new DaySeeker( filter );
            Day targetDay = seeker.FindDay( new Day( startDate ), noOfBusinessDays );
            return targetDay.Start;
        }
Example #2
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 ) ) );
        }
Example #3
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
        }