Files
klz-cables.com/.pnpm-store/v10/files/ed/02bb695cdcf89ebe5e0f9b7b774d5cb5aa106c11e4c63c81f642c250f3b7a4eb9e6cc52d4bc37790bf68caa1d3cd3498750538bcb00c043c781b16e3aeeb9f
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
927 B
Plaintext

import { daysInWeek } from "./constants.mjs";
/**
* @name daysToWeeks
* @category Conversion Helpers
* @summary Convert days to weeks.
*
* @description
* Convert a number of days to a full number of weeks.
*
* @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 days - The number of days to be converted
*
* @returns The number of days converted in weeks
*
* @example
* // Convert 14 days to weeks:
* const result = daysToWeeks(14)
* //=> 2
*
* @example
* // It uses trunc rounding:
* const result = daysToWeeks(13)
* //=> 1
*/
export function daysToWeeks(days) {
const weeks = days / daysInWeek;
const result = Math.trunc(weeks);
// Prevent negative zero
return result === 0 ? 0 : result;
}
// Fallback for modularized imports:
export default daysToWeeks;