UNPKG

1.39 kBTypeScriptView Raw
1import type { RoundingOptions } from "./types.js";
2/**
3 * The {@link differenceInMinutes} function options.
4 */
5export interface DifferenceInMinutesOptions extends RoundingOptions {}
6/**
7 * @name differenceInMinutes
8 * @category Minute Helpers
9 * @summary Get the number of minutes between the given dates.
10 *
11 * @description
12 * Get the signed number of full (rounded towards 0) minutes between the given dates.
13 *
14 * @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).
15 *
16 * @param dateLeft - The later date
17 * @param dateRight - The earlier date
18 * @param options - An object with options.
19 *
20 * @returns The number of minutes
21 *
22 * @example
23 * // How many minutes are between 2 July 2014 12:07:59 and 2 July 2014 12:20:00?
24 * const result = differenceInMinutes(
25 * new Date(2014, 6, 2, 12, 20, 0),
26 * new Date(2014, 6, 2, 12, 7, 59)
27 * )
28 * //=> 12
29 *
30 * @example
31 * // How many minutes are between 10:01:59 and 10:00:00
32 * const result = differenceInMinutes(
33 * new Date(2000, 0, 1, 10, 0, 0),
34 * new Date(2000, 0, 1, 10, 1, 59)
35 * )
36 * //=> -1
37 */
38export declare function differenceInMinutes<DateType extends Date>(
39 dateLeft: DateType | number | string,
40 dateRight: DateType | number | string,
41 options?: DifferenceInMinutesOptions,
42): number;