private const int AverageDaysPer10Years = 3652; // Ideally 365.2425 per year...

        static GregorianYearMonthDayCalculator()
        {
            // It's generally a really bad idea to create an instance before the static initializer
            // has completed, but we know its safe because we're only using a very restricted set of methods.
            var instance = new GregorianYearMonthDayCalculator();
            for (int year = FirstOptimizedYear; year <= LastOptimizedYear; year++)
            {
                int yearStart = instance.CalculateStartOfYearDays(year);
                YearStartDays[year - FirstOptimizedYear] = yearStart;
                int monthStartDay = yearStart - 1; // See field description
                int yearMonthIndex = (year - FirstOptimizedYear) * 12;
                for (int month = 1; month <= 12; month++)
                {
                    yearMonthIndex++;
                    int monthLength = instance.GetDaysInMonth(year, month);
                    MonthStartDays[yearMonthIndex] = monthStartDay;
                    monthStartDay += monthLength;
                }
            }
        }
        private const int AverageDaysPer10Years = 3652; // Ideally 365.2425 per year...

        static GregorianYearMonthDayCalculator()
        {
            // It's generally a really bad idea to create an instance before the static initializer
            // has completed, but we know its safe because we're only using a very restricted set of methods.
            var instance = new GregorianYearMonthDayCalculator();

            for (int year = FirstOptimizedYear; year <= LastOptimizedYear; year++)
            {
                int yearStart = instance.CalculateStartOfYearDays(year);
                YearStartDays[year - FirstOptimizedYear] = yearStart;
                int monthStartDay  = yearStart - 1; // See field description
                int yearMonthIndex = (year - FirstOptimizedYear) * 12;
                for (int month = 1; month <= 12; month++)
                {
                    yearMonthIndex++;
                    int monthLength = instance.GetDaysInMonth(year, month);
                    MonthStartDays[yearMonthIndex] = monthStartDay;
                    monthStartDay += monthLength;
                }
            }
        }
Exemplo n.º 3
0
 static CalendarSystem()
 {
     var gregorianCalculator = new GregorianYearMonthDayCalculator();
     var gregorianEraCalculator = new GJEraCalculator(gregorianCalculator);
     IsoCalendarSystem = new CalendarSystem(CalendarOrdinal.Iso, IsoId, IsoName, gregorianCalculator, 4, gregorianEraCalculator);
 }