* Generates header button text (month and year) for a specific month timestamp * @private
(monthTimestamp: number)
| 445 | * @private |
| 446 | */ |
| 447 | _getHeaderTextForMonth(monthTimestamp: number): { monthText: string, yearText: string, secondMonthText?: string, secondYearText?: string } { |
| 448 | const calendarDate = CalendarDateComponent.fromTimestamp(monthTimestamp * 1000, this._primaryCalendarType); |
| 449 | const localeData = getCachedLocaleDataInstance(getLocale()); |
| 450 | const yearFormat = DateFormat.getDateInstance({ format: "y", calendarType: this._primaryCalendarType }); |
| 451 | |
| 452 | const monthText = localeData.getMonthsStandAlone("wide", this._primaryCalendarType)[calendarDate.getMonth()]; |
| 453 | const localDate = calendarDate.toLocalJSDate(); |
| 454 | const yearText = String(yearFormat.format(localDate, true)); |
| 455 | |
| 456 | const result: { monthText: string, yearText: string, secondMonthText?: string, secondYearText?: string } = { |
| 457 | monthText, |
| 458 | yearText, |
| 459 | }; |
| 460 | |
| 461 | if (this.hasSecondaryCalendarType) { |
| 462 | const secondaryDate = transformDateToSecondaryType(this._primaryCalendarType, this._secondaryCalendarType, monthTimestamp, true); |
| 463 | const secondaryCalendarDate = secondaryDate.firstDate || secondaryDate.lastDate; |
| 464 | const secondaryLocaleData = getCachedLocaleDataInstance(getLocale()); |
| 465 | result.secondMonthText = secondaryLocaleData.getMonthsStandAlone("wide", this._secondaryCalendarType)[secondaryCalendarDate.getMonth()]; |
| 466 | const secondaryYearFormat = DateFormat.getDateInstance({ format: "y", calendarType: this._secondaryCalendarType }); |
| 467 | result.secondYearText = String(secondaryYearFormat.format(secondaryCalendarDate.toLocalJSDate(), true)); |
| 468 | } |
| 469 | |
| 470 | return result; |
| 471 | } |
| 472 | |
| 473 | /** |
| 474 | * @private |
no test coverage detected