1 | import type {
|
2 | ContextOptions,
|
3 | DateArg,
|
4 | FirstWeekContainsDateOptions,
|
5 | LocalizedOptions,
|
6 | WeekOptions,
|
7 | } from "./types.js";
|
8 | /**
|
9 | * The {@link getWeek} function options.
|
10 | */
|
11 | export interface GetWeekOptions
|
12 | extends LocalizedOptions<"options">,
|
13 | WeekOptions,
|
14 | FirstWeekContainsDateOptions,
|
15 | ContextOptions<Date> {}
|
16 | /**
|
17 | * @name getWeek
|
18 | * @category Week Helpers
|
19 | * @summary Get the local week index of the given date.
|
20 | *
|
21 | * @description
|
22 | * Get the local week index of the given date.
|
23 | * The exact calculation depends on the values of
|
24 | * `options.weekStartsOn` (which is the index of the first day of the week)
|
25 | * and `options.firstWeekContainsDate` (which is the day of January, which is always in
|
26 | * the first week of the week-numbering year)
|
27 | *
|
28 | * Week numbering: https://en.wikipedia.org/wiki/Week#The_ISO_week_date_system
|
29 | *
|
30 | * @param date - The given date
|
31 | * @param options - An object with options
|
32 | *
|
33 | * @returns The week
|
34 | *
|
35 | * @example
|
36 | * // Which week of the local week numbering year is 2 January 2005 with default options?
|
37 | * const result = getWeek(new Date(2005, 0, 2))
|
38 | * //=> 2
|
39 | *
|
40 | * @example
|
41 | * // Which week of the local week numbering year is 2 January 2005,
|
42 | * // if Monday is the first day of the week,
|
43 | * // and the first week of the year always contains 4 January?
|
44 | * const result = getWeek(new Date(2005, 0, 2), {
|
45 | * weekStartsOn: 1,
|
46 | * firstWeekContainsDate: 4
|
47 | * })
|
48 | * //=> 53
|
49 | */
|
50 | export declare function getWeek(
|
51 | date: DateArg<Date> & {},
|
52 | options?: GetWeekOptions | undefined,
|
53 | ): number;
|