UNPKG

901 BTypeScriptView Raw
1/**
2 * @name differenceInCalendarYears
3 * @category Year Helpers
4 * @summary Get the number of calendar years between the given dates.
5 *
6 * @description
7 * Get the number of calendar years between the given dates.
8 *
9 * @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).
10 *
11 * @param dateLeft - The later date
12 * @param dateRight - The earlier date
13
14 * @returns The number of calendar years
15 *
16 * @example
17 * // How many calendar years are between 31 December 2013 and 11 February 2015?
18 * const result = differenceInCalendarYears(
19 * new Date(2015, 1, 11),
20 * new Date(2013, 11, 31)
21 * )
22 * //=> 2
23 */
24export declare function differenceInCalendarYears<DateType extends Date>(
25 dateLeft: DateType | number | string,
26 dateRight: DateType | number | string,
27): number;