Files
klz-cables.com/.pnpm-store/v10/files/b1/714ec497c35c43db1cae7f7d356374a4edc48b4cbada3b827670fa00a6a52f4bf6037fd8b861eb9c7920b07a2f67f18fc7419b1cf335ff36ee8f03546b44db
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

35 lines
1.0 KiB
Plaintext

import { toDate } from "./toDate.mjs";
/**
* @name differenceInCalendarYears
* @category Year Helpers
* @summary Get the number of calendar years between the given dates.
*
* @description
* Get the number of calendar years 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
* @returns The number of calendar years
*
* @example
* // How many calendar years are between 31 December 2013 and 11 February 2015?
* const result = differenceInCalendarYears(
* new Date(2015, 1, 11),
* new Date(2013, 11, 31)
* )
* //=> 2
*/
export function differenceInCalendarYears(dateLeft, dateRight) {
const _dateLeft = toDate(dateLeft);
const _dateRight = toDate(dateRight);
return _dateLeft.getFullYear() - _dateRight.getFullYear();
}
// Fallback for modularized imports:
export default differenceInCalendarYears;