Inheritance: QuarterTimeRange
示例#1
0
        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 ) ) );
        }
示例#2
0
        public void FourthCustomCalendarQuartersTest()
        {
            TimeCalendar calendar = TimeCalendar.New( YearMonth.October );
            const int startYear = 2004;
            const YearQuarter startQuarter = YearQuarter.Fourth;
            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.Fourth );
            Assert.AreEqual( quarters.GetQuarters().Count, quarterCount );
            Assert.IsTrue( quarters.GetQuarters()[ 0 ].IsSamePeriod( new Quarter( 2004, YearQuarter.Fourth, calendar ) ) );
            Assert.IsTrue( quarters.GetQuarters()[ 1 ].IsSamePeriod( new Quarter( 2005, YearQuarter.First, calendar ) ) );
            Assert.IsTrue( quarters.GetQuarters()[ 2 ].IsSamePeriod( new Quarter( 2005, YearQuarter.Second, calendar ) ) );
            Assert.IsTrue( quarters.GetQuarters()[ 3 ].IsSamePeriod( new Quarter( 2005, YearQuarter.Third, calendar ) ) );
            Assert.IsTrue( quarters.GetQuarters()[ 4 ].IsSamePeriod( new Quarter( 2005, YearQuarter.Fourth, calendar ) ) );
        }
示例#3
0
        // ----------------------------------------------------------------------
        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();
        }
示例#4
0
 public void YearBaseMonthTest()
 {
     DateTime moment = new DateTime( 2009, 2, 15 );
     int year = TimeTool.GetYearOf( YearMonth.April, moment.Year, moment.Month );
     Quarters quarters = new Quarters( moment, YearQuarter.First, 3, TimeCalendar.New( YearMonth.April ) );
     Assert.AreEqual( quarters.YearBaseMonth, YearMonth.April );
     Assert.AreEqual( quarters.Start, new DateTime( year, (int)YearMonth.April, 1 ) );
 }
示例#5
0
        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 ) ) );
        }
示例#6
0
 // ----------------------------------------------------------------------
 public static void ShowQuarters( Quarters quarters, string caption = "Quarters" )
 {
     WriteLine( "{0}: {1}", caption, quarters );
     WriteIndentLine( "YearBaseMonth: {0}", quarters.YearBaseMonth );
     WriteIndentLine( "StartYear: {0}", quarters.StartYear );
     WriteIndentLine( "StartQuarter: {0}", quarters.StartQuarter );
     WriteIndentLine( "StartQuarterName: {0}", quarters.StartQuarterName );
     WriteIndentLine( "StartQuarterOfYearName: {0}", quarters.StartQuarterOfYearName );
     WriteIndentLine( "EndYear: {0}", quarters.EndYear );
     WriteIndentLine( "EndQuarter: {0}", quarters.EndQuarter );
     WriteIndentLine( "EndQuarterName: {0}", quarters.EndQuarterName );
     WriteIndentLine( "EndQuarterOfYearName: {0}", quarters.EndQuarterOfYearName );
     WriteIndentLine( "FirstDayStart: {0}", Format( quarters.FirstDayStart ) );
     WriteIndentLine( "LastDayStart: {0}", Format( quarters.LastDayStart ) );
     WriteLine();
 }
示例#7
0
 // ----------------------------------------------------------------------
 public static void ShowCompactQuarters( Quarters quarters, string caption = "Quarters" )
 {
     WriteLine( "{0}: {1}", caption, quarters );
 }
示例#8
0
 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
 }