1 | import type { ContextOptions, DateArg } from "./types.js";
|
2 | /**
|
3 | * The {@link min} function options.
|
4 | */
|
5 | export interface MinOptions<DateType extends Date = Date>
|
6 | extends ContextOptions<DateType> {}
|
7 | /**
|
8 | * @name min
|
9 | * @category Common Helpers
|
10 | * @summary Returns the earliest of the given dates.
|
11 | *
|
12 | * @description
|
13 | * Returns the earliest of the given dates.
|
14 | *
|
15 | * @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).
|
16 | * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
17 | *
|
18 | * @param dates - The dates to compare
|
19 | *
|
20 | * @returns The earliest of the dates
|
21 | *
|
22 | * @example
|
23 | * // Which of these dates is the earliest?
|
24 | * const result = min([
|
25 | * new Date(1989, 6, 10),
|
26 | * new Date(1987, 1, 11),
|
27 | * new Date(1995, 6, 2),
|
28 | * new Date(1990, 0, 1)
|
29 | * ])
|
30 | * //=> Wed Feb 11 1987 00:00:00
|
31 | */
|
32 | export declare function min<
|
33 | DateType extends Date,
|
34 | ResultDate extends Date = DateType,
|
35 | >(
|
36 | dates: Array<DateArg<DateType>>,
|
37 | options?: MinOptions<ResultDate> | undefined,
|
38 | ): ResultDate;
|