Rocky_Mountain_Vending/.pnpm-store/v10/files/67/08d6e634fc27e4aead5e09c68dd5f624bc6a8dd15239aaac60780bcfa7dc9a2fa87d700cdff4a6ba8f174d503622a7a32da23d078393b8a0dd0e0777f961d3
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

50 lines
No EOL
2.2 KiB
Text

/**
* Returns all the dates to display in the calendar.
*
* This function calculates the range of dates to display based on the provided
* display months, constraints, and calendar configuration.
*
* @param displayMonths The months to display in the calendar.
* @param maxDate The maximum date to include in the range.
* @param props The DayPicker props, including calendar configuration options.
* @param dateLib The date library to use for date manipulation.
* @returns An array of dates to display in the calendar.
*/
export function getDates(displayMonths, maxDate, props, dateLib) {
const firstMonth = displayMonths[0];
const lastMonth = displayMonths[displayMonths.length - 1];
const { ISOWeek, fixedWeeks, broadcastCalendar } = props ?? {};
const { addDays, differenceInCalendarDays, differenceInCalendarMonths, endOfBroadcastWeek, endOfISOWeek, endOfMonth, endOfWeek, isAfter, startOfBroadcastWeek, startOfISOWeek, startOfWeek } = dateLib;
const startWeekFirstDate = broadcastCalendar
? startOfBroadcastWeek(firstMonth, dateLib)
: ISOWeek
? startOfISOWeek(firstMonth)
: startOfWeek(firstMonth);
const endWeekLastDate = broadcastCalendar
? endOfBroadcastWeek(lastMonth)
: ISOWeek
? endOfISOWeek(endOfMonth(lastMonth))
: endOfWeek(endOfMonth(lastMonth));
const nOfDays = differenceInCalendarDays(endWeekLastDate, startWeekFirstDate);
const nOfMonths = differenceInCalendarMonths(lastMonth, firstMonth) + 1;
const dates = [];
for (let i = 0; i <= nOfDays; i++) {
const date = addDays(startWeekFirstDate, i);
if (maxDate && isAfter(date, maxDate)) {
break;
}
dates.push(date);
}
// If fixed weeks is enabled, add the extra dates to the array
const nrOfDaysWithFixedWeeks = broadcastCalendar ? 35 : 42;
const extraDates = nrOfDaysWithFixedWeeks * nOfMonths;
if (fixedWeeks && dates.length < extraDates) {
const daysToAdd = extraDates - dates.length;
for (let i = 0; i < daysToAdd; i++) {
const date = addDays(dates[dates.length - 1], 1);
dates.push(date);
}
}
return dates;
}
//# sourceMappingURL=getDates.js.map