UNPKG

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