UNPKG

537 BPlain TextView Raw
1import type { DateLib, DayPickerProps } from "../types/index.js";
2
3export function getDisplayMonths(
4 firstDisplayedMonth: Date,
5 calendarEndMonth: Date | undefined,
6 props: Pick<DayPickerProps, "numberOfMonths">,
7 dateLib: DateLib
8) {
9 const { numberOfMonths = 1 } = props;
10 const months: Date[] = [];
11 for (let i = 0; i < numberOfMonths; i++) {
12 const month = dateLib.addMonths(firstDisplayedMonth, i);
13 if (calendarEndMonth && month > calendarEndMonth) {
14 break;
15 }
16 months.push(month);
17 }
18 return months;
19}