UNPKG

1.49 kBTypeScriptView Raw
1import type { LocalizedOptions, WeekOptions } from "./types.js";
2/**
3 * The {@link differenceInCalendarWeeks} function options.
4 */
5export interface DifferenceInCalendarWeeksOptions
6 extends LocalizedOptions<"options">,
7 WeekOptions {}
8/**
9 * @name differenceInCalendarWeeks
10 * @category Week Helpers
11 * @summary Get the number of calendar weeks between the given dates.
12 *
13 * @description
14 * Get the number of calendar weeks between the given dates.
15 *
16 * @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).
17 *
18 * @param dateLeft - The later date
19 * @param dateRight - The earlier date
20 * @param options - An object with options.
21 *
22 * @returns The number of calendar weeks
23 *
24 * @example
25 * // How many calendar weeks are between 5 July 2014 and 20 July 2014?
26 * const result = differenceInCalendarWeeks(
27 * new Date(2014, 6, 20),
28 * new Date(2014, 6, 5)
29 * )
30 * //=> 3
31 *
32 * @example
33 * // If the week starts on Monday,
34 * // how many calendar weeks are between 5 July 2014 and 20 July 2014?
35 * const result = differenceInCalendarWeeks(
36 * new Date(2014, 6, 20),
37 * new Date(2014, 6, 5),
38 * { weekStartsOn: 1 }
39 * )
40 * //=> 2
41 */
42export declare function differenceInCalendarWeeks<DateType extends Date>(
43 dateLeft: DateType | number | string,
44 dateRight: DateType | number | string,
45 options?: DifferenceInCalendarWeeksOptions,
46): number;