registration

This commit is contained in:
User
2025-02-02 16:08:03 +03:00
parent 7f6495eb4d
commit 78afbaed71
6334 changed files with 196774 additions and 165754 deletions

View File

@@ -1,13 +1,19 @@
"use strict";
exports.eachQuarterOfInterval = eachQuarterOfInterval;
var _index = require("./addQuarters.js");
var _index2 = require("./startOfQuarter.js");
var _index3 = require("./toDate.js");
import { normalizeInterval } from "./_lib/normalizeInterval.js";
import { addQuarters } from "./addQuarters.js";
import { constructFrom } from "./constructFrom.js";
import { startOfQuarter } from "./startOfQuarter.js";
/**
* The {@link eachQuarterOfInterval} function options.
*/
/**
* The {@link eachQuarterOfInterval} function result type. It resolves the proper data type.
* It uses the first argument date object type, starting from the date argument,
* then the start interval date, and finally the end interval date. If
* a context function is passed, it uses the context function return type.
*/
/**
* @name eachQuarterOfInterval
* @category Interval Helpers
@@ -16,9 +22,11 @@ var _index3 = require("./toDate.js");
* @description
* Return the array of quarters within the specified time interval.
*
* @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).
* @typeParam IntervalType - Interval type.
* @typeParam Options - Options type.
*
* @param interval - The interval
* @param options - An object with options
*
* @returns The array with starts of quarters from the quarter of the interval start to the quarter of the interval end
*
@@ -26,7 +34,7 @@ var _index3 = require("./toDate.js");
* // Each quarter within interval 6 February 2014 - 10 August 2014:
* const result = eachQuarterOfInterval({
* start: new Date(2014, 1, 6),
* end: new Date(2014, 7, 10)
* end: new Date(2014, 7, 10),
* })
* //=> [
* // Wed Jan 01 2014 00:00:00,
@@ -34,17 +42,12 @@ var _index3 = require("./toDate.js");
* // Tue Jul 01 2014 00:00:00,
* // ]
*/
function eachQuarterOfInterval(interval, options) {
const startDate = (0, _index3.toDate)(interval.start);
const endDate = (0, _index3.toDate)(interval.end);
export function eachQuarterOfInterval(interval, options) {
const { start, end } = normalizeInterval(options?.in, interval);
let reversed = +startDate > +endDate;
const endTime = reversed
? +(0, _index2.startOfQuarter)(startDate)
: +(0, _index2.startOfQuarter)(endDate);
let currentDate = reversed
? (0, _index2.startOfQuarter)(endDate)
: (0, _index2.startOfQuarter)(startDate);
let reversed = +start > +end;
const endTime = reversed ? +startOfQuarter(start) : +startOfQuarter(end);
let date = reversed ? startOfQuarter(end) : startOfQuarter(start);
let step = options?.step ?? 1;
if (!step) return [];
@@ -55,10 +58,13 @@ function eachQuarterOfInterval(interval, options) {
const dates = [];
while (+currentDate <= endTime) {
dates.push((0, _index3.toDate)(currentDate));
currentDate = (0, _index.addQuarters)(currentDate, step);
while (+date <= endTime) {
dates.push(constructFrom(start, date));
date = addQuarters(date, step);
}
return reversed ? dates.reverse() : dates;
}
// Fallback for modularized imports:
export default eachQuarterOfInterval;