UNPKG

1.27 kBTypeScriptView Raw
1import type { Interval, StepOptions } from "./types.js";
2/**
3 * The {@link eachYearOfInterval} function options.
4 */
5export interface EachYearOfIntervalOptions extends StepOptions {}
6/**
7 * @name eachYearOfInterval
8 * @category Interval Helpers
9 * @summary Return the array of yearly timestamps within the specified time interval.
10 *
11 * @description
12 * Return the array of yearly timestamps 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 *
18 * @returns The array with starts of yearly timestamps from the month of the interval start to the month of the interval end
19 *
20 * @example
21 * // Each year between 6 February 2014 and 10 August 2017:
22 * const result = eachYearOfInterval({
23 * start: new Date(2014, 1, 6),
24 * end: new Date(2017, 7, 10)
25 * })
26 * //=> [
27 * // Wed Jan 01 2014 00:00:00,
28 * // Thu Jan 01 2015 00:00:00,
29 * // Fri Jan 01 2016 00:00:00,
30 * // Sun Jan 01 2017 00:00:00
31 * // ]
32 */
33export declare function eachYearOfInterval<DateType extends Date>(
34 interval: Interval<DateType>,
35 options?: EachYearOfIntervalOptions,
36): DateType[];