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

41 lines
1.3 KiB
Plaintext

import { getRoundingMethod } from "./_lib/getRoundingMethod.mjs";
import { millisecondsInHour } from "./constants.mjs";
import { differenceInMilliseconds } from "./differenceInMilliseconds.mjs";
/**
* The {@link differenceInHours} function options.
*/
/**
* @name differenceInHours
* @category Hour Helpers
* @summary Get the number of hours between the given dates.
*
* @description
* Get the number of hours between the given dates.
*
* @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 dateLeft - The later date
* @param dateRight - The earlier date
* @param options - An object with options.
*
* @returns The number of hours
*
* @example
* // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00?
* const result = differenceInHours(
* new Date(2014, 6, 2, 19, 0),
* new Date(2014, 6, 2, 6, 50)
* )
* //=> 12
*/
export function differenceInHours(dateLeft, dateRight, options) {
const diff =
differenceInMilliseconds(dateLeft, dateRight) / millisecondsInHour;
return getRoundingMethod(options?.roundingMethod)(diff);
}
// Fallback for modularized imports:
export default differenceInHours;