Files
klz-cables.com/.pnpm-store/v10/files/44/4e358fa14ff0f2a321870bec3c49496c431beb8dcdc72724d8456005536b5a4b6986c2662712437aa684d5096cec01ca67116ed240fb9abb80af222c6d7b4a
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

36 lines
1.1 KiB
Plaintext

import { addDays } from "./addDays.mjs";
import { getISODay } from "./getISODay.mjs";
import { toDate } from "./toDate.mjs";
/**
* @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).
*
* @param date - The date to be changed
* @param day - The day of the ISO week of the new date
*
* @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) {
const _date = toDate(date);
const currentDay = getISODay(_date);
const diff = day - currentDay;
return addDays(_date, diff);
}
// Fallback for modularized imports:
export default setISODay;