UNPKG

1.22 kBTypeScriptView Raw
1import type { ContextOptions, DateArg } from "./types.js";
2/**
3 * The {@link subDays} function options.
4 */
5export interface SubDaysOptions<DateType extends Date = Date>
6 extends ContextOptions<DateType> {}
7/**
8 * @name subDays
9 * @category Day Helpers
10 * @summary Subtract the specified number of days from the given date.
11 *
12 * @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).
13 * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
14 *
15 * @param date - The date to be changed
16 * @param amount - The amount of days to be subtracted.
17 * @param options - An object with options
18 *
19 * @returns The new date with the days subtracted
20 *
21 * @example
22 * // Subtract 10 days from 1 September 2014:
23 * const result = subDays(new Date(2014, 8, 1), 10)
24 * //=> Fri Aug 22 2014 00:00:00
25 */
26export declare function subDays<
27 DateType extends Date,
28 ResultDate extends Date = DateType,
29>(
30 date: DateArg<DateType>,
31 amount: number,
32 options?: SubDaysOptions<ResultDate> | undefined,
33): ResultDate;