GetNextYear() 공개 메소드

public GetNextYear ( ) : Year
리턴 Year
예제 #1
0
        // ----------------------------------------------------------------------
        public static void ShowAll( int periodCount, int startYear, TimeCalendarConfig calendarConfig )
        {
            WriteLine( "Input: count={0}, year={1}", periodCount, startYear );
            WriteLine( "Calendar: base-month={0}, week-type={1}, culture={2}", calendarConfig.YearBaseMonth,  calendarConfig.YearWeekType, calendarConfig.Culture.Name );

            WriteLine();

            YearTimeRange yearTimeRange;
            if ( periodCount == 1 )
            {
                Year year = new Year( startYear, new TimeCalendar( calendarConfig ) );
                yearTimeRange = year;

                Year previousYear = year.GetPreviousYear();
                Year nextYears = year.GetNextYear();

                ShowYear( year );
                ShowCompactYear( previousYear, "Previous Year" );
                ShowCompactYear( nextYears, "Next Year" );
                WriteLine();
            }
            else
            {
                Years years = new Years( startYear, periodCount, new TimeCalendar( calendarConfig ) );
                yearTimeRange = years;

                ShowYears( years );
                WriteLine();

                foreach ( Year year in years.GetYears() )
                {
                    ShowCompactYear( year );
                }
                WriteLine();
            }

            foreach ( Halfyear halfyear in yearTimeRange.GetHalfyears() )
            {
                HalfyearDemo.ShowCompactHalfyear( halfyear );
            }
            WriteLine();
            foreach ( Quarter quarter in yearTimeRange.GetQuarters() )
            {
                QuarterDemo.ShowCompactQuarter( quarter );
            }
            WriteLine();
            foreach ( Month month in yearTimeRange.GetMonths() )
            {
                MonthDemo.ShowCompactMonth( month );
            }
            WriteLine();
        }
        } // StartPeriodVisit

        // ----------------------------------------------------------------------
        protected Year StartYearVisit(Year year, TContext context = null, SeekDirection?visitDirection = null)
        {
            if (year == null)
            {
                throw new ArgumentNullException("year");
            }

            if (visitDirection == null)
            {
                visitDirection = SeekDirection;
            }

            OnVisitStart();

            // iteration limits
            Year     lastVisited = null;
            DateTime minStart    = DateTime.MinValue;
            DateTime maxEnd      = DateTime.MaxValue.AddYears(-1);

            while (year.Start > minStart && year.End < maxEnd)
            {
                if (OnVisitYear(year, context) == false)
                {
                    lastVisited = year;
                    break;
                }
                switch (visitDirection)
                {
                case SeekDirection.Forward:
                    year = year.GetNextYear();
                    break;

                case SeekDirection.Backward:
                    year = year.GetPreviousYear();
                    break;
                }
            }

            OnVisitEnd();

            return(lastVisited);
        } // StartYearVisit
예제 #3
0
        public void YearCompareTest()
        {
            DateTime moment = new DateTime( 2008, 2, 18 );
            Year calendarYearSweden = new Year( moment, TimeCalendar.New( YearMonth.January ) );
            Assert.AreEqual( calendarYearSweden.YearBaseMonth, YearMonth.January );

            Year calendarYearGermany = new Year( moment, TimeCalendar.New( YearMonth.April ) );
            Assert.AreEqual( calendarYearGermany.YearBaseMonth, YearMonth.April );

            Year calendarYearUnitedStates = new Year( moment, TimeCalendar.New( YearMonth.October ) );
            Assert.AreEqual( calendarYearUnitedStates.YearBaseMonth, YearMonth.October );

            Assert.AreNotEqual( calendarYearSweden, calendarYearGermany );
            Assert.AreNotEqual( calendarYearSweden, calendarYearUnitedStates );
            Assert.AreNotEqual( calendarYearGermany, calendarYearUnitedStates );

            Assert.AreEqual( calendarYearSweden.BaseYear, calendarYearGermany.BaseYear + 1 );
            Assert.AreEqual( calendarYearSweden.BaseYear, calendarYearUnitedStates.BaseYear + 1 );

            Assert.AreEqual( calendarYearSweden.GetPreviousYear().BaseYear, calendarYearGermany.GetPreviousYear().BaseYear + 1 );
            Assert.AreEqual( calendarYearSweden.GetPreviousYear().BaseYear, calendarYearUnitedStates.GetPreviousYear().BaseYear + 1 );

            Assert.AreEqual( calendarYearSweden.GetNextYear().BaseYear, calendarYearGermany.GetNextYear().BaseYear + 1 );
            Assert.AreEqual( calendarYearSweden.GetNextYear().BaseYear, calendarYearUnitedStates.GetNextYear().BaseYear + 1 );

            Assert.IsTrue( calendarYearSweden.IntersectsWith( calendarYearGermany ) );
            Assert.IsTrue( calendarYearSweden.IntersectsWith( calendarYearUnitedStates ) );
            Assert.IsTrue( calendarYearGermany.IntersectsWith( calendarYearUnitedStates ) );
        }
예제 #4
0
        public void GetNextYearTest()
        {
            DateTime currentYearStart = new DateTime( ClockProxy.Clock.Now.Year, 4, 1 );

            Year currentYear = new Year( currentYearStart.Year, TimeCalendar.New( TimeSpan.Zero, TimeSpan.Zero, YearMonth.April ) );

            Year nextYear = currentYear.GetNextYear();
            Assert.IsTrue( nextYear.IsReadOnly );
            Assert.AreEqual( nextYear.YearBaseMonth, YearMonth.April );
            Assert.AreEqual( nextYear.BaseYear, currentYearStart.Year + 1 );
            Assert.AreEqual( nextYear.Start, currentYearStart.AddYears( 1 ) );
            Assert.AreEqual( nextYear.End, currentYearStart.AddYears( 2 ) );
        }
예제 #5
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;
     }
 }