UNPKG

1.06 kBTypeScriptView Raw
1import type {
2 ContextOptions,
3 DateArg,
4 LocalizedOptions,
5 WeekOptions,
6} from "./types.js";
7/**
8 * The {@link getWeeksInMonth} function options.
9 */
10export interface GetWeeksInMonthOptions
11 extends LocalizedOptions<"options">,
12 WeekOptions,
13 ContextOptions<Date> {}
14/**
15 * @name getWeeksInMonth
16 * @category Week Helpers
17 * @summary Get the number of calendar weeks a month spans.
18 *
19 * @description
20 * Get the number of calendar weeks the month in the given date spans.
21 *
22 * @param date - The given date
23 * @param options - An object with options.
24 *
25 * @returns The number of calendar weeks
26 *
27 * @example
28 * // How many calendar weeks does February 2015 span?
29 * const result = getWeeksInMonth(new Date(2015, 1, 8))
30 * //=> 4
31 *
32 * @example
33 * // If the week starts on Monday,
34 * // how many calendar weeks does July 2017 span?
35 * const result = getWeeksInMonth(new Date(2017, 6, 5), { weekStartsOn: 1 })
36 * //=> 6
37 */
38export declare function getWeeksInMonth(
39 date: DateArg<Date> & {},
40 options?: GetWeeksInMonthOptions | undefined,
41): number;