registration
This commit is contained in:
39
frontend/style/node_modules/date-fns/eachMonthOfInterval.js
generated
vendored
39
frontend/style/node_modules/date-fns/eachMonthOfInterval.js
generated
vendored
@@ -1,11 +1,14 @@
|
||||
"use strict";
|
||||
exports.eachMonthOfInterval = eachMonthOfInterval;
|
||||
var _index = require("./toDate.js");
|
||||
import { normalizeInterval } from "./_lib/normalizeInterval.js";
|
||||
import { constructFrom } from "./constructFrom.js";
|
||||
|
||||
/**
|
||||
* The {@link eachMonthOfInterval} function options.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The {@link eachMonthOfInterval} function result type. It resolves the proper data type.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name eachMonthOfInterval
|
||||
* @category Interval Helpers
|
||||
@@ -14,9 +17,11 @@ var _index = require("./toDate.js");
|
||||
* @description
|
||||
* Return the array of months 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 interval - The interval.
|
||||
* @param options - An object with options.
|
||||
*
|
||||
* @returns The array with starts of months from the month of the interval start to the month of the interval end
|
||||
*
|
||||
@@ -36,15 +41,14 @@ var _index = require("./toDate.js");
|
||||
* // Fri Aug 01 2014 00:00:00
|
||||
* // ]
|
||||
*/
|
||||
function eachMonthOfInterval(interval, options) {
|
||||
const startDate = (0, _index.toDate)(interval.start);
|
||||
const endDate = (0, _index.toDate)(interval.end);
|
||||
export function eachMonthOfInterval(interval, options) {
|
||||
const { start, end } = normalizeInterval(options?.in, interval);
|
||||
|
||||
let reversed = +startDate > +endDate;
|
||||
const endTime = reversed ? +startDate : +endDate;
|
||||
const currentDate = reversed ? endDate : startDate;
|
||||
currentDate.setHours(0, 0, 0, 0);
|
||||
currentDate.setDate(1);
|
||||
let reversed = +start > +end;
|
||||
const endTime = reversed ? +start : +end;
|
||||
const date = reversed ? end : start;
|
||||
date.setHours(0, 0, 0, 0);
|
||||
date.setDate(1);
|
||||
|
||||
let step = options?.step ?? 1;
|
||||
if (!step) return [];
|
||||
@@ -55,10 +59,13 @@ function eachMonthOfInterval(interval, options) {
|
||||
|
||||
const dates = [];
|
||||
|
||||
while (+currentDate <= endTime) {
|
||||
dates.push((0, _index.toDate)(currentDate));
|
||||
currentDate.setMonth(currentDate.getMonth() + step);
|
||||
while (+date <= endTime) {
|
||||
dates.push(constructFrom(start, date));
|
||||
date.setMonth(date.getMonth() + step);
|
||||
}
|
||||
|
||||
return reversed ? dates.reverse() : dates;
|
||||
}
|
||||
|
||||
// Fallback for modularized imports:
|
||||
export default eachMonthOfInterval;
|
||||
|
||||
Reference in New Issue
Block a user