Rocky_Mountain_Vending/.pnpm-store/v10/files/97/9a0b96c716a1f6ff8e6c5f65e2436998a4f25ea536546c4ea1b1bf6b3339d61c09ba9edc7c02f176007b8140905b8fd04a1505d574d85a4f999c8175553733
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

52 lines
1.4 KiB
Text

import { type DateLib } from "../classes/DateLib.js";
import { type DayPickerProps } from "../types/props.js";
/**
* Determines the initial month to display in the calendar based on the provided
* props.
*
* This function calculates the starting month, considering constraints such as
* `startMonth`, `endMonth`, and the number of months to display.
*
* @param props The DayPicker props, including navigation and date constraints.
* @param dateLib The date library to use for date manipulation.
* @returns The initial month to display.
*/
export function getInitialMonth(
props: Pick<
DayPickerProps,
| "fromYear"
| "toYear"
| "month"
| "defaultMonth"
| "today"
| "numberOfMonths"
| "timeZone"
>,
navStart: Date | undefined,
navEnd: Date | undefined,
dateLib: DateLib
): Date {
const {
month,
defaultMonth,
today = dateLib.today(),
numberOfMonths = 1
} = props;
let initialMonth = month || defaultMonth || today;
const { differenceInCalendarMonths, addMonths, startOfMonth } = dateLib;
if (
navEnd &&
differenceInCalendarMonths(navEnd, initialMonth) < numberOfMonths - 1
) {
const offset = -1 * (numberOfMonths - 1);
initialMonth = addMonths(navEnd, offset);
}
if (navStart && differenceInCalendarMonths(initialMonth, navStart) < 0) {
initialMonth = navStart;
}
return startOfMonth(initialMonth);
}