react-day-picker
Version:
Customizable Date Picker for React
21 lines (20 loc) • 712 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDays = getDays;
/**
* Returns all the days belonging to the calendar by merging the days in the
* weeks for each month.
*
* @param calendarMonths The array of calendar months.
* @returns An array of `CalendarDay` objects representing all the days in the
* calendar.
*/
function getDays(calendarMonths) {
const initialDays = [];
return calendarMonths.reduce((days, month) => {
const weekDays = month.weeks.reduce((weekDays, week) => {
return weekDays.concat(week.days.slice());
}, initialDays.slice());
return days.concat(weekDays.slice());
}, initialDays.slice());
}