1 | import type {
|
2 | ContextOptions,
|
3 | DateArg,
|
4 | LocalizedOptions,
|
5 | WeekOptions,
|
6 | } from "./types.js";
|
7 | /**
|
8 | * The {@link setDay} function options.
|
9 | */
|
10 | export interface SetDayOptions<DateType extends Date = Date>
|
11 | extends LocalizedOptions<"options">,
|
12 | WeekOptions,
|
13 | ContextOptions<DateType> {}
|
14 | /**
|
15 | * @name setDay
|
16 | * @category Weekday Helpers
|
17 | * @summary Set the day of the week to the given date.
|
18 | *
|
19 | * @description
|
20 | * Set the day of the week to the given date.
|
21 | *
|
22 | * @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).
|
23 | * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
24 | *
|
25 | * @param date - The date to be changed
|
26 | * @param day - The day of the week of the new date
|
27 | * @param options - An object with options.
|
28 | *
|
29 | * @returns The new date with the day of the week set
|
30 | *
|
31 | * @example
|
32 | * // Set week day to Sunday, with the default weekStartsOn of Sunday:
|
33 | * const result = setDay(new Date(2014, 8, 1), 0)
|
34 | * //=> Sun Aug 31 2014 00:00:00
|
35 | *
|
36 | * @example
|
37 | * // Set week day to Sunday, with a weekStartsOn of Monday:
|
38 | * const result = setDay(new Date(2014, 8, 1), 0, { weekStartsOn: 1 })
|
39 | * //=> Sun Sep 07 2014 00:00:00
|
40 | */
|
41 | export declare function setDay<
|
42 | DateType extends Date,
|
43 | ResultDate extends Date = DateType,
|
44 | >(
|
45 | date: DateArg<DateType>,
|
46 | day: number,
|
47 | options?: SetDayOptions<ResultDate>,
|
48 | ): ResultDate;
|