private int GetDaysInFirstWeek(int year, GregorianCalendarSystem calendar)
 {
     // Some of the first few days of the week year may be in the previous week year.
     // However, the whole of the first week of the week year definitely occurs
     // within the first 13 days of January.
     return Enumerable.Range(1, 13)
                      .Count(day => new LocalDate(year, 1, day, calendar).WeekOfWeekYear == 1);
 }
 static GregorianCalendarSystem()
 {
     GregorianCache = new GregorianCalendarSystem[7];
     for (int i = 0; i < 7; i++)
     {
         GregorianCache[i] = new GregorianCalendarSystem(GregorianName, i + 1, null);
     }
     IsoInstance = new GregorianCalendarSystem(IsoName, 4, AssembleIsoFields);
     
     for (int year = FirstOptimizedYear; year <= LastOptimizedYear; year++)
     {
         for (int month = 1; month <= 12; month++)
         {
             int yearMonthIndex = (year - FirstOptimizedYear) * 12 + month;
             MonthStartTicks[yearMonthIndex] = IsoInstance.GetYearMonthTicks(year, month);
             MonthLengths[yearMonthIndex] = IsoInstance.GetDaysInMonth(year, month);
         }
     }
 }