UNPKG

1.26 kBTypeScriptView Raw
1import type { ContextOptions, DateArg } from "./types.js";
2/**
3 * The {@link setISOWeek} function options.
4 */
5export interface SetISOWeekOptions<DateType extends Date = Date>
6 extends ContextOptions<DateType> {}
7/**
8 * @name setISOWeek
9 * @category ISO Week Helpers
10 * @summary Set the ISO week to the given date.
11 *
12 * @description
13 * Set the ISO week to the given date, saving the weekday number.
14 *
15 * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
16 *
17 * @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).
18 * @typeParam ResultDate - The `Date` type of the context function.
19 *
20 * @param date - The date to be changed
21 * @param week - The ISO week of the new date
22 * @param options - An object with options
23 *
24 * @returns The new date with the ISO week set
25 *
26 * @example
27 * // Set the 53rd ISO week to 7 August 2004:
28 * const result = setISOWeek(new Date(2004, 7, 7), 53)
29 * //=> Sat Jan 01 2005 00:00:00
30 */
31export declare function setISOWeek<
32 DateType extends Date,
33 ResultDate extends Date = DateType,
34>(
35 date: DateArg<DateType>,
36 week: number,
37 options?: SetISOWeekOptions<ResultDate>,
38): ResultDate;