MCPcopy Create free account
hub / github.com/UI5/webcomponents / _getHeaderTextForMonth

Method _getHeaderTextForMonth

packages/main/src/Calendar.ts:447–471  ·  view source on GitHub ↗

* Generates header button text (month and year) for a specific month timestamp * @private

(monthTimestamp: number)

Source from the content-addressed store, hash-verified

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

Callers 2

renderMonthHeadersFunction · 0.80
renderMonthPickersFunction · 0.80

Calls 8

getLocaleFunction · 0.85
fromTimestampMethod · 0.80
getDateInstanceMethod · 0.80
getMonthMethod · 0.80
toLocalJSDateMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected