getMonthsInYear method

int getMonthsInYear(
  1. int year
)

Returns the maximum valid month (inclusive) within this calendar in the given year.

It is assumed that in all calendars, every month between 1 and this month number is valid for the given year. This does not necessarily mean that the first month of the year is 1, however. (See the Hebrew calendar system using the scriptural month numbering system for example.)

  • year: The year to consider.

Returns: The maximum month number within the given year.

  • ArgumentOutOfRangeException: The given year is invalid for this calendar.

Note that some implementations may return a month rather than throw this exception (for example, if all years have the same number of months in this calendar system). Failure to throw an exception should not be treated as an indication that the year is valid.

Implementation

int getMonthsInYear(int year) {
  Preconditions.checkArgumentRange('year', year, minYear, maxYear);
  return _yearMonthDayCalculator.getMonthsInYear(year);
}