GetHalfyears() public method

public GetHalfyears ( ) : ITimePeriodCollection
return ITimePeriodCollection
コード例 #1
0
ファイル: HalfyearsTest.cs プロジェクト: jwg4/date-difference
        public void FirstCalendarHalfyearsTest()
        {
            const int startYear = 2004;
            const YearHalfyear startHalfyear = YearHalfyear.First;
            const int halfyearCount = 3;
            Halfyears halfyears = new Halfyears( startYear, startHalfyear, halfyearCount );

            Assert.AreEqual( halfyears.YearBaseMonth, YearMonth.January );
            Assert.AreEqual( halfyears.HalfyearCount, halfyearCount );
            Assert.AreEqual( halfyears.StartHalfyear, startHalfyear );
            Assert.AreEqual( halfyears.StartYear, startYear );
            Assert.AreEqual( halfyears.EndYear, 2005 );
            Assert.AreEqual( halfyears.EndHalfyear, YearHalfyear.First );
            Assert.AreEqual( halfyears.GetHalfyears().Count, halfyearCount );
            Assert.IsTrue( halfyears.GetHalfyears()[ 0 ].IsSamePeriod( new Halfyear( 2004, YearHalfyear.First ) ) );
            Assert.IsTrue( halfyears.GetHalfyears()[ 1 ].IsSamePeriod( new Halfyear( 2004, YearHalfyear.Second ) ) );
            Assert.IsTrue( halfyears.GetHalfyears()[ 2 ].IsSamePeriod( new Halfyear( 2005, YearHalfyear.First ) ) );
        }
コード例 #2
0
ファイル: HalfyearsTest.cs プロジェクト: jwg4/date-difference
        public void FirstCustomCalendarHalfyearsTest()
        {
            TimeCalendar calendar = TimeCalendar.New( YearMonth.October );
            const int startYear = 2004;
            const YearHalfyear startHalfyear = YearHalfyear.First;
            const int halfyearCount = 3;
            Halfyears halfyears = new Halfyears( startYear, startHalfyear, halfyearCount, calendar );

            Assert.AreEqual( halfyears.YearBaseMonth, YearMonth.October );
            Assert.AreEqual( halfyears.HalfyearCount, halfyearCount );
            Assert.AreEqual( halfyears.StartHalfyear, startHalfyear );
            Assert.AreEqual( halfyears.StartYear, startYear );
            Assert.AreEqual( halfyears.EndYear, 2005 );
            Assert.AreEqual( halfyears.EndHalfyear, YearHalfyear.First );
            Assert.AreEqual( halfyears.GetHalfyears().Count, halfyearCount );
            Assert.IsTrue( halfyears.GetHalfyears()[ 0 ].IsSamePeriod( new Halfyear( 2004, YearHalfyear.First, calendar ) ) );
            Assert.IsTrue( halfyears.GetHalfyears()[ 1 ].IsSamePeriod( new Halfyear( 2004, YearHalfyear.Second, calendar ) ) );
            Assert.IsTrue( halfyears.GetHalfyears()[ 2 ].IsSamePeriod( new Halfyear( 2005, YearHalfyear.First, calendar ) ) );
        }
コード例 #3
0
ファイル: HalfyearDemo.cs プロジェクト: jwg4/date-difference
        // ----------------------------------------------------------------------
        public static void ShowAll( int periodCount, int startYear, YearHalfyear yearHalfyear, TimeCalendarConfig calendarConfig )
        {
            WriteLine( "Input: count={0}, year={1}, halfyear={2}", periodCount, startYear, yearHalfyear );
            WriteLine();

            HalfyearTimeRange halfyearTimeRange;
            if ( periodCount == 1 )
            {
                Halfyear halfyear = new Halfyear( startYear, yearHalfyear, new TimeCalendar( calendarConfig ) );
                halfyearTimeRange = halfyear;

                Halfyear previousHalfyear = halfyear.GetPreviousHalfyear();
                Halfyear nextHalfyear = halfyear.GetNextHalfyear();

                ShowHalfyear( halfyear );
                ShowCompactHalfyear( previousHalfyear, "Previous Halfyear" );
                ShowCompactHalfyear( nextHalfyear, "Next Halfyear" );
                WriteLine();
            }
            else
            {
                Halfyears halfyears = new Halfyears( startYear, yearHalfyear, periodCount, new TimeCalendar( calendarConfig ) );
                halfyearTimeRange = halfyears;

                ShowHalfyears( halfyears );
                WriteLine();

                foreach ( Halfyear halfyear in halfyears.GetHalfyears() )
                {
                    ShowCompactHalfyear( halfyear );
                }
                WriteLine();
            }

            foreach ( Quarter quarter in halfyearTimeRange.GetQuarters() )
            {
                QuarterDemo.ShowCompactQuarter( quarter );
            }
            WriteLine();
            foreach ( Month month in halfyearTimeRange.GetMonths() )
            {
                MonthDemo.ShowCompactMonth( month );
            }
            WriteLine();
        }
コード例 #4
0
ファイル: HalfyearsTest.cs プロジェクト: jwg4/date-difference
        public void SingleHalfyearsTest()
        {
            const int startYear = 2004;
            const YearHalfyear startHalfyear = YearHalfyear.Second;
            Halfyears halfyears = new Halfyears( startYear, startHalfyear, 1 );

            Assert.AreEqual( halfyears.YearBaseMonth, YearMonth.January );
            Assert.AreEqual( halfyears.HalfyearCount, 1 );
            Assert.AreEqual( halfyears.StartHalfyear, startHalfyear );
            Assert.AreEqual( halfyears.StartYear, startYear );
            Assert.AreEqual( halfyears.EndYear, startYear );
            Assert.AreEqual( halfyears.EndHalfyear, YearHalfyear.Second );
            Assert.AreEqual( halfyears.GetHalfyears().Count, 1 );
            Assert.IsTrue( halfyears.GetHalfyears()[ 0 ].IsSamePeriod( new Halfyear( 2004, YearHalfyear.Second ) ) );
        }