Rocky_Mountain_Vending/.pnpm-store/v10/files/98/f7d49fe7ce7db4e22c50785b5c13999c73d5146e7737cd7033ae9aa5a862f501289bbe8d4436d24e7f419563e2aa7e976f317701a6cd8dd965db3345da9656
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

33 lines
1.1 KiB
Text

import { defaultDateLib, type DateLib } from "../classes/DateLib.js";
/**
* Checks if a date range contains one or more specified days of the week.
*
* @since 9.2.2
* @param range - The date range to check.
* @param dayOfWeek - The day(s) of the week to check for (`0-6`, where `0` is
* Sunday).
* @param dateLib - The date utility library instance.
* @returns `true` if the range contains the specified day(s) of the week,
* otherwise `false`.
* @group Utilities
*/
export function rangeContainsDayOfWeek(
range: { from: Date; to: Date },
dayOfWeek: number | number[],
dateLib: DateLib = defaultDateLib
) {
const dayOfWeekArr = !Array.isArray(dayOfWeek) ? [dayOfWeek] : dayOfWeek;
let date = range.from;
const totalDays = dateLib.differenceInCalendarDays(range.to, range.from);
// iterate at maximum one week or the total days if the range is shorter than one week
const totalDaysLimit = Math.min(totalDays, 6);
for (let i = 0; i <= totalDaysLimit; i++) {
if (dayOfWeekArr.includes(date.getDay())) {
return true;
}
date = dateLib.addDays(date, 1);
}
return false;
}