UNPKG

ngx-bootstrap

Version:
33 lines 1.5 kB
import { formatDate, getLocale } from 'ngx-bootstrap/chronos'; export function formatDaysCalendar(daysCalendar, formatOptions, monthIndex) { return { month: daysCalendar.month, monthTitle: formatDate(daysCalendar.month, formatOptions.monthTitle, formatOptions.locale), yearTitle: formatDate(daysCalendar.month, formatOptions.yearTitle, formatOptions.locale), weekNumbers: getWeekNumbers(daysCalendar.daysMatrix, formatOptions.weekNumbers, formatOptions.locale), weekdays: getShiftedWeekdays(formatOptions.locale), weeks: daysCalendar.daysMatrix.map((week, weekIndex) => ({ days: week.map((date, dayIndex) => ({ date, label: formatDate(date, formatOptions.dayLabel, formatOptions.locale), monthIndex, weekIndex, dayIndex })) })), hideLeftArrow: false, hideRightArrow: false, disableLeftArrow: false, disableRightArrow: false }; } export function getWeekNumbers(daysMatrix, format, locale) { return daysMatrix.map((days) => (days[0] ? formatDate(days[0], format, locale) : '')); } export function getShiftedWeekdays(locale) { const _locale = getLocale(locale); const weekdays = _locale.weekdaysShort(); const firstDayOfWeek = _locale.firstDayOfWeek(); return [...weekdays.slice(firstDayOfWeek), ...weekdays.slice(0, firstDayOfWeek)]; } //# sourceMappingURL=format-days-calendar.js.map