private static void AddNonCalendarYearQuarter(StringBuilder sb, TimePoint point)
 {
     sb.Append(point.Year);
     sb.Append("/");
     sb.Append(GetLastTwoDigits(point.Year + 1));
     sb.Append(" Q");
     sb.Append(point.Quarter);
 }
 private static void AddMonthAndYear(TimePoint point, StringBuilder sb)
 {
     int month = point.Month;
     if (month > 0 && month < 13)
     {
         sb.Append(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(point.Month).Substring(0, 3));
     }
     else
     {
         sb.Append(month);
     }
     sb.Append(" ");
     sb.Append(point.Year);
 }
 private static void AddCalendarYearQuarter(StringBuilder sb, TimePoint point)
 {
     sb.Append(point.Year);
     sb.Append(" Q");
     sb.Append(point.Quarter);
 }
        private static string FormatQuarter(TimePeriod period, int yearTypeId)
        {
            StringBuilder sb = new StringBuilder();
            TimePoint point;

            switch (yearTypeId)
            {
                case YearTypeIds.FinancialRollingYearQuarterly:
                    AddNonCalendarYearQuarter(sb, period);
                    sb.Append(" - ");
                    AddNonCalendarYearQuarter(sb, period.GetRollingQuarterlyEndPoint());
                    break;

                case YearTypeIds.CalendarRollingYearQuarterly:
                    AddCalendarYearQuarter(sb, period);
                    sb.Append(" - ");
                    AddCalendarYearQuarter(sb, period.GetRollingQuarterlyEndPoint());
                    break;

                case YearTypeIds.FinancialSingleYearCumulativeQuarter:
                    point = new TimePoint { Year = period.Year, Quarter = 1 };
                    AddNonCalendarYearQuarter(sb, point);
                    if (period.Quarter > 1)
                    {
                        sb.Append("-Q");
                        sb.Append(period.Quarter);
                    }
                    break;

                case YearTypeIds.FinancialMultiYearCumulativeQuarter:

                    // Starting quarter
                    point = new TimePoint { Year = period.Year, Quarter = 1 };
                    AddNonCalendarYearQuarter(sb, point);

                    // Final quarter

                    if (period.Quarter > 1)
                    {
                        sb.Append(" - ");

                        int yearDifference = (int)Math.Ceiling(period.Quarter / 4.0) - 1;
                        point = new TimePoint {
                            Year = point.Year + yearDifference,
                            Quarter = EnsureQuarterIsFourOrLess(period.Quarter)
                        };
                        AddNonCalendarYearQuarter(sb, point);
                    }
                    break;

                default:
                    if (DoesYearNotBeginInJanuary(yearTypeId))
                    {
                        AddNonCalendarYearQuarter(sb, period);
                    }
                    else
                    {
                        AddCalendarYearQuarter(sb, period);
                    }

                    break;
            }

            return sb.ToString();
        }