// ---------------------------------------------------------------------- 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(); }
public void SecondCalendarHalfyearsTest() { const int startYear = 2004; const YearHalfyear startHalfyear = YearHalfyear.Second; 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.Second ); Assert.AreEqual( halfyears.GetHalfyears().Count, halfyearCount ); Assert.IsTrue( halfyears.GetHalfyears()[ 0 ].IsSamePeriod( new Halfyear( 2004, YearHalfyear.Second ) ) ); Assert.IsTrue( halfyears.GetHalfyears()[ 1 ].IsSamePeriod( new Halfyear( 2005, YearHalfyear.First ) ) ); Assert.IsTrue( halfyears.GetHalfyears()[ 2 ].IsSamePeriod( new Halfyear( 2005, YearHalfyear.Second ) ) ); }
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 ) ) ); }
public void YearBaseMonthTest() { DateTime moment = new DateTime( 2009, 2, 15 ); int year = TimeTool.GetYearOf( YearMonth.April, moment.Year, moment.Month ); Halfyears halfyears = new Halfyears( moment, YearHalfyear.First, 3, TimeCalendar.New( YearMonth.April ) ); Assert.AreEqual( halfyears.YearBaseMonth, YearMonth.April ); Assert.AreEqual( halfyears.Start, new DateTime( year, (int)YearMonth.April, 1 ) ); }
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 ) ) ); }
// ---------------------------------------------------------------------- public static void ShowCompactHalfyears( Halfyears halfyears, string caption = "Halfyears" ) { WriteLine( "{0}: {1}", caption, halfyears ); }
// ---------------------------------------------------------------------- public static void ShowHalfyears( Halfyears halfyears, string caption = "Halfyears" ) { WriteLine( "{0}: {1}", caption, halfyears ); WriteIndentLine( "YearBaseMonth: {0}", halfyears.YearBaseMonth ); WriteIndentLine( "StartYear: {0}", halfyears.StartYear ); WriteIndentLine( "StartHalfyear: {0}", halfyears.StartHalfyear ); WriteIndentLine( "StartHalfyearName: {0}", halfyears.StartHalfyearName ); WriteIndentLine( "StartHalfyearOfYearName: {0}", halfyears.StartHalfyearOfYearName ); WriteIndentLine( "EndYear: {0}", halfyears.EndYear ); WriteIndentLine( "EndHalfyear: {0}", halfyears.EndHalfyear ); WriteIndentLine( "EndHalfyearName: {0}", halfyears.EndHalfyearName ); WriteIndentLine( "EndHalfyearOfYearName: {0}", halfyears.EndHalfyearOfYearName ); WriteLine(); }