Rocky_Mountain_Vending/.pnpm-store/v10/files/b8/f65224cbbab54598f0cf4afd6583c7ddb975694f072b865feb913ef3fd57daebe3e3af3ff0f52ee5cd171344c6d03a24ef587945cd4934437599266aa0bb49
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

41 lines
1.4 KiB
Text

import { addDays } from "./addDays.js";
import { getISODay } from "./getISODay.js";
import { toDate } from "./toDate.js";
/**
* The {@link setISODay} function options.
*/
/**
* @name setISODay
* @category Weekday Helpers
* @summary Set the day of the ISO week to the given date.
*
* @description
* Set the day of the ISO week to the given date.
* ISO week starts with Monday.
* 7 is the index of Sunday, 1 is the index of Monday, etc.
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param day - The day of the ISO week of the new date
* @param options - An object with options
*
* @returns The new date with the day of the ISO week set
*
* @example
* // Set Sunday to 1 September 2014:
* const result = setISODay(new Date(2014, 8, 1), 7)
* //=> Sun Sep 07 2014 00:00:00
*/
export function setISODay(date, day, options) {
const date_ = toDate(date, options?.in);
const currentDay = getISODay(date_, options);
const diff = day - currentDay;
return addDays(date_, diff, options);
}
// Fallback for modularized imports:
export default setISODay;