Files
klz-cables.com/.pnpm-store/v10/files/c8/c8a54a44809ec481f0f8e75851adcd2888312fde39688334afd03cd408023d5ac29d21fd6bc164b3f23b529efe81915e22152893c3a143f780d5dabf488081
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

57 lines
1.6 KiB
Plaintext

import { normalizeInterval } from "./_lib/normalizeInterval.js";
import { constructFrom } from "./constructFrom.js";
import { eachDayOfInterval } from "./eachDayOfInterval.js";
import { isWeekend } from "./isWeekend.js";
/**
* The {@link eachWeekendOfInterval} function options.
*/
/**
* The {@link eachWeekendOfInterval} function result type.
*/
/**
* @name eachWeekendOfInterval
* @category Interval Helpers
* @summary List all the Saturdays and Sundays in the given date interval.
*
* @description
* Get all the Saturdays and Sundays in the given date interval.
*
* @typeParam IntervalType - Interval type.
* @typeParam Options - Options type.
*
* @param interval - The given interval
* @param options - An object with options
*
* @returns An array containing all the Saturdays and Sundays
*
* @example
* // Lists all Saturdays and Sundays in the given date interval
* const result = eachWeekendOfInterval({
* start: new Date(2018, 8, 17),
* end: new Date(2018, 8, 30)
* })
* //=> [
* // Sat Sep 22 2018 00:00:00,
* // Sun Sep 23 2018 00:00:00,
* // Sat Sep 29 2018 00:00:00,
* // Sun Sep 30 2018 00:00:00
* // ]
*/
export function eachWeekendOfInterval(interval, options) {
const { start, end } = normalizeInterval(options?.in, interval);
const dateInterval = eachDayOfInterval({ start, end }, options);
const weekends = [];
let index = 0;
while (index < dateInterval.length) {
const date = dateInterval[index++];
if (isWeekend(date)) weekends.push(constructFrom(start, date));
}
return weekends;
}
// Fallback for modularized imports:
export default eachWeekendOfInterval;