// ---------------------------------------------------------------------- public static void ShowAll( int periodCount, int startYear, YearQuarter yearQuarter, TimeCalendarConfig calendarConfig ) { WriteLine( "Input: count={0}, year={1}, quarter={2}", periodCount, startYear, yearQuarter ); WriteLine(); QuarterTimeRange quarterTimeRange; if ( periodCount == 1 ) { Quarter quarter = new Quarter( startYear, yearQuarter, new TimeCalendar( calendarConfig ) ); quarterTimeRange = quarter; Quarter previousQuarter = quarter.GetPreviousQuarter(); Quarter nextQuarter = quarter.GetNextQuarter(); ShowQuarter( quarter ); ShowCompactQuarter( previousQuarter, "Previous Quarter" ); ShowCompactQuarter( nextQuarter, "Next Quarter" ); WriteLine(); } else { Quarters quarters = new Quarters( startYear, yearQuarter, periodCount, new TimeCalendar( calendarConfig ) ); quarterTimeRange = quarters; ShowQuarters( quarters ); WriteLine(); foreach ( Quarter quarter in quarters.GetQuarters() ) { ShowCompactQuarter( quarter ); } WriteLine(); } foreach ( Month month in quarterTimeRange.GetMonths() ) { MonthDemo.ShowCompactMonth( month ); } WriteLine(); }
public void FirstCalendarQuartersTest() { const int startYear = 2004; const YearQuarter startQuarter = YearQuarter.First; const int quarterCount = 5; Quarters quarters = new Quarters( startYear, startQuarter, quarterCount ); Assert.AreEqual( quarters.YearBaseMonth, YearMonth.January ); Assert.AreEqual( quarters.QuarterCount, quarterCount ); Assert.AreEqual( quarters.StartQuarter, startQuarter ); Assert.AreEqual( quarters.StartYear, startYear ); Assert.AreEqual( quarters.EndYear, 2005 ); Assert.AreEqual( quarters.EndQuarter, YearQuarter.First ); Assert.AreEqual( quarters.GetQuarters().Count, quarterCount ); Assert.IsTrue( quarters.GetQuarters()[ 0 ].IsSamePeriod( new Quarter( 2004, YearQuarter.First ) ) ); Assert.IsTrue( quarters.GetQuarters()[ 1 ].IsSamePeriod( new Quarter( 2004, YearQuarter.Second ) ) ); Assert.IsTrue( quarters.GetQuarters()[ 2 ].IsSamePeriod( new Quarter( 2004, YearQuarter.Third ) ) ); Assert.IsTrue( quarters.GetQuarters()[ 3 ].IsSamePeriod( new Quarter( 2004, YearQuarter.Fourth ) ) ); Assert.IsTrue( quarters.GetQuarters()[ 4 ].IsSamePeriod( new Quarter( 2005, YearQuarter.First ) ) ); }
public void FirstCustomCalendarQuartersTest() { TimeCalendar calendar = TimeCalendar.New( YearMonth.October ); const int startYear = 2004; const YearQuarter startQuarter = YearQuarter.First; const int quarterCount = 5; Quarters quarters = new Quarters( startYear, startQuarter, quarterCount, calendar ); Assert.AreEqual( quarters.YearBaseMonth, YearMonth.October ); Assert.AreEqual( quarters.QuarterCount, quarterCount ); Assert.AreEqual( quarters.StartQuarter, startQuarter ); Assert.AreEqual( quarters.StartYear, startYear ); Assert.AreEqual( quarters.EndYear, 2005 ); Assert.AreEqual( quarters.EndQuarter, YearQuarter.First ); Assert.AreEqual( quarters.GetQuarters().Count, quarterCount ); Assert.IsTrue( quarters.GetQuarters()[ 0 ].IsSamePeriod( new Quarter( 2004, YearQuarter.First, calendar ) ) ); Assert.IsTrue( quarters.GetQuarters()[ 1 ].IsSamePeriod( new Quarter( 2004, YearQuarter.Second, calendar ) ) ); Assert.IsTrue( quarters.GetQuarters()[ 2 ].IsSamePeriod( new Quarter( 2004, YearQuarter.Third, calendar ) ) ); Assert.IsTrue( quarters.GetQuarters()[ 3 ].IsSamePeriod( new Quarter( 2004, YearQuarter.Fourth, calendar ) ) ); Assert.IsTrue( quarters.GetQuarters()[ 4 ].IsSamePeriod( new Quarter( 2005, YearQuarter.First, calendar ) ) ); }
public void SingleQuartersTest() { const int startYear = 2004; const YearQuarter startQuarter = YearQuarter.Second; Quarters quarters = new Quarters( startYear, startQuarter, 1 ); Assert.AreEqual( quarters.YearBaseMonth, YearMonth.January ); Assert.AreEqual( quarters.QuarterCount, 1 ); Assert.AreEqual( quarters.StartQuarter, startQuarter ); Assert.AreEqual( quarters.StartYear, startYear ); Assert.AreEqual( quarters.EndYear, startYear ); Assert.AreEqual( quarters.EndQuarter, YearQuarter.Second ); Assert.AreEqual( quarters.GetQuarters().Count, 1 ); Assert.IsTrue( quarters.GetQuarters()[ 0 ].IsSamePeriod( new Quarter( 2004, YearQuarter.Second ) ) ); }
public void QuarterSample() { Quarters quarters = new Quarters( 2006, YearQuarter.First, 6 ); Console.WriteLine( "Quarters of: {0}", quarters ); // > Quarters of: Q1 2006 - Q3 2007; 01.01.2006 - 30.06.2007 | 545.23:59 foreach ( Quarter quarter in quarters.GetQuarters() ) { Console.WriteLine( "Quarter: {0}", quarter ); } // > Quarter: Q1 2006; 01.01.2006 - 31.03.2006 | 89.23:59 // > Quarter: Q2 2006; 01.04.2006 - 30.06.2006 | 90.23:59 // > Quarter: Q3 2006; 01.07.2006 - 30.09.2006 | 91.23:59 // > Quarter: Q4 2006; 01.10.2006 - 31.12.2006 | 91.23:59 // > Quarter: Q1 2007; 01.01.2007 - 31.03.2007 | 89.23:59 // > Quarter: Q2 2007; 01.04.2007 - 30.06.2007 | 90.23:59 }