()
| 199 | } |
| 200 | |
| 201 | _getYearRanges() { |
| 202 | const yearFormat = DateFormat.getDateInstance({ format: "y", calendarType: this._primaryCalendarType }); |
| 203 | const yearFormatInSecType = DateFormat.getDateInstance({ format: "y", calendarType: this._secondaryCalendarType }); |
| 204 | |
| 205 | const pageSize = this._getPageSize(); |
| 206 | const rowSize = this._getRowSize(); |
| 207 | const rangeSize = this._getRangeSize(); |
| 208 | |
| 209 | const calendarDate = this._calendarDate; |
| 210 | const minYear = this._minDate.getYear(); |
| 211 | const maxYear = this._maxDate.getYear(); |
| 212 | |
| 213 | const tempDate = new CalendarDate(calendarDate, this._primaryCalendarType); |
| 214 | tempDate.setYear(this._gridStartYear!); |
| 215 | |
| 216 | const yearRanges: YearRanges = []; |
| 217 | |
| 218 | for (let i = 0; i < pageSize; i++) { |
| 219 | const endDate = new CalendarDate(tempDate, this._primaryCalendarType); |
| 220 | endDate.setYear(endDate.getYear() + rangeSize - 1); |
| 221 | |
| 222 | const timestamp = tempDate.valueOf() / 1000; |
| 223 | const endTimestamp = endDate.valueOf() / 1000; |
| 224 | |
| 225 | const isFocused = isBetweenInclusive(calendarDate.getYear(), tempDate.getYear(), endDate.getYear()); |
| 226 | |
| 227 | const isSelected = this._isYearRangeSelected(timestamp, endTimestamp); |
| 228 | const isSelectedBetween = this._isInsideSelectionRange(timestamp); |
| 229 | |
| 230 | const yearRangeText = this._getYearRangeFormattedText(tempDate, endDate, yearFormat); |
| 231 | const secYearRangeText = this.hasSecondaryCalendarType ? this._getYearRangeFormattedText(tempDate, endDate, yearFormatInSecType) : undefined; |
| 232 | |
| 233 | const isDisabled = !(isBetweenInclusive(tempDate.getYear(), minYear, maxYear) |
| 234 | || isBetweenInclusive(endDate.getYear(), minYear, maxYear)); |
| 235 | |
| 236 | const yearRange = this._getYearRange(timestamp, isFocused, isSelected, isSelectedBetween, yearRangeText, secYearRangeText, isDisabled); |
| 237 | |
| 238 | const intervalIndex = Math.floor(i / rowSize); |
| 239 | |
| 240 | if (yearRanges[intervalIndex]) { |
| 241 | yearRanges[intervalIndex].push(yearRange); |
| 242 | } else { |
| 243 | yearRanges[intervalIndex] = [yearRange]; |
| 244 | } |
| 245 | |
| 246 | tempDate.setYear(tempDate.getYear() + rangeSize); |
| 247 | } |
| 248 | |
| 249 | return yearRanges; |
| 250 | } |
| 251 | |
| 252 | _getYearRange(timestamp: number, isFocused: boolean, isSelected: boolean, isSelectedBetween: boolean, yearRangeText: string, secYearRangeText: string | undefined, isDisabled: boolean) { |
| 253 | const yearRange: YearRange = { |
no test coverage detected