Files
klz-cables.com/.pnpm-store/v10/files/04/1297ea13cf26c0a9ddcc28bd319850fa592e251330b9910063f4ca55833f6d8a07eca24d939e01c7f1ccbda55a479a523599f0f3039121f680142c537724a5
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

58 lines
1.4 KiB
Plaintext

"use strict";
exports.isWithinInterval = isWithinInterval;
var _index = require("./toDate.cjs");
/**
* The {@link isWithinInterval} function options.
*/
/**
* @name isWithinInterval
* @category Interval Helpers
* @summary Is the given date within the interval?
*
* @description
* Is the given date within the interval? (Including start and end.)
*
* @param date - The date to check
* @param interval - The interval to check
* @param options - An object with options
*
* @returns The date is within the interval
*
* @example
* // For the date within the interval:
* isWithinInterval(new Date(2014, 0, 3), {
* start: new Date(2014, 0, 1),
* end: new Date(2014, 0, 7)
* })
* // => true
*
* @example
* // For the date outside of the interval:
* isWithinInterval(new Date(2014, 0, 10), {
* start: new Date(2014, 0, 1),
* end: new Date(2014, 0, 7)
* })
* // => false
*
* @example
* // For date equal to the interval start:
* isWithinInterval(date, { start, end: date })
* // => true
*
* @example
* // For date equal to the interval end:
* isWithinInterval(date, { start: date, end })
* // => true
*/
function isWithinInterval(date, interval, options) {
const time = +(0, _index.toDate)(date, options?.in);
const [startTime, endTime] = [
+(0, _index.toDate)(interval.start, options?.in),
+(0, _index.toDate)(interval.end, options?.in),
].sort((a, b) => a - b);
return time >= startTime && time <= endTime;
}