UNPKG

1.51 kBTypeScriptView Raw
1import type { ContextOptions, DateArg } from "./types.js";
2/**
3 * The {@link setISOWeekYear} function options.
4 */
5export interface SetISOWeekYearOptions<DateType extends Date = Date>
6 extends ContextOptions<DateType> {}
7/**
8 * @name setISOWeekYear
9 * @category ISO Week-Numbering Year Helpers
10 * @summary Set the ISO week-numbering year to the given date.
11 *
12 * @description
13 * Set the ISO week-numbering year to the given date,
14 * saving the week number and the weekday number.
15 *
16 * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
17 *
18 * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows using extensions like [`UTCDate`](https://github.com/date-fns/utc).
19 * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
20 *
21 * @param date - The date to be changed
22 * @param weekYear - The ISO week-numbering year of the new date
23 * @param options - An object with options
24 *
25 * @returns The new date with the ISO week-numbering year set
26 *
27 * @example
28 * // Set ISO week-numbering year 2007 to 29 December 2008:
29 * const result = setISOWeekYear(new Date(2008, 11, 29), 2007)
30 * //=> Mon Jan 01 2007 00:00:00
31 */
32export declare function setISOWeekYear<
33 DateType extends Date,
34 ResultDate extends Date = DateType,
35>(
36 date: DateArg<DateType>,
37 weekYear: number,
38 options?: SetISOWeekYearOptions<ResultDate> | undefined,
39): ResultDate;