1 | import type { ContextOptions, DateArg } from "./types.js";
|
2 | /**
|
3 | * The {@link max} function options.
|
4 | */
|
5 | export interface MaxOptions<DateType extends Date = Date>
|
6 | extends ContextOptions<DateType> {}
|
7 | /**
|
8 | * @name max
|
9 | * @category Common Helpers
|
10 | * @summary Return the latest of the given dates.
|
11 | *
|
12 | * @description
|
13 | * Return the latest 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 latest of the dates
|
21 | *
|
22 | * @example
|
23 | * // Which of these dates is the latest?
|
24 | * const result = max([
|
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 | * //=> Sun Jul 02 1995 00:00:00
|
31 | */
|
32 | export declare function max<
|
33 | DateType extends Date,
|
34 | ResultDate extends Date = DateType,
|
35 | >(
|
36 | dates: DateArg<DateType>[],
|
37 | options?: MaxOptions<ResultDate> | undefined,
|
38 | ): ResultDate;
|