UNPKG

1.3 kBTypeScriptView Raw
1import type { Interval, StepOptions } from "./types.js";
2/**
3 * The {@link eachHourOfInterval} function options.
4 */
5export interface EachHourOfIntervalOptions extends StepOptions {}
6/**
7 * @name eachHourOfInterval
8 * @category Interval Helpers
9 * @summary Return the array of hours within the specified time interval.
10 *
11 * @description
12 * Return the array of hours within the specified time interval.
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 interval - The interval.
17 * @param options - An object with options.
18 *
19 * @returns The array with starts of hours from the hour of the interval start to the hour of the interval end
20 *
21 * @example
22 * // Each hour between 6 October 2014, 12:00 and 6 October 2014, 15:00
23 * const result = eachHourOfInterval({
24 * start: new Date(2014, 9, 6, 12),
25 * end: new Date(2014, 9, 6, 15)
26 * })
27 * //=> [
28 * // Mon Oct 06 2014 12:00:00,
29 * // Mon Oct 06 2014 13:00:00,
30 * // Mon Oct 06 2014 14:00:00,
31 * // Mon Oct 06 2014 15:00:00
32 * // ]
33 */
34export declare function eachHourOfInterval<DateType extends Date>(
35 interval: Interval<DateType>,
36 options?: EachHourOfIntervalOptions,
37): DateType[];