UNPKG

922 BTypeScriptView Raw
1import type { ContextOptions, Duration, Interval } from "./types.js";
2/**
3 * The {@link intervalToDuration} function options.
4 */
5export interface IntervalToDurationOptions extends ContextOptions<Date> {}
6/**
7 * @name intervalToDuration
8 * @category Common Helpers
9 * @summary Convert interval to duration
10 *
11 * @description
12 * Convert an interval object to a duration object.
13 *
14 * @param interval - The interval to convert to duration
15 * @param options - The context options
16 *
17 * @returns The duration object
18 *
19 * @example
20 * // Get the duration between January 15, 1929 and April 4, 1968.
21 * intervalToDuration({
22 * start: new Date(1929, 0, 15, 12, 0, 0),
23 * end: new Date(1968, 3, 4, 19, 5, 0)
24 * });
25 * //=> { years: 39, months: 2, days: 20, hours: 7, minutes: 5, seconds: 0 }
26 */
27export declare function intervalToDuration(
28 interval: Interval,
29 options?: IntervalToDurationOptions | undefined,
30): Duration;