registration
This commit is contained in:
42
frontend/style/node_modules/date-fns/eachMinuteOfInterval.js
generated
vendored
42
frontend/style/node_modules/date-fns/eachMinuteOfInterval.js
generated
vendored
@@ -1,13 +1,18 @@
|
||||
"use strict";
|
||||
exports.eachMinuteOfInterval = eachMinuteOfInterval;
|
||||
var _index = require("./addMinutes.js");
|
||||
var _index2 = require("./startOfMinute.js");
|
||||
var _index3 = require("./toDate.js");
|
||||
import { normalizeInterval } from "./_lib/normalizeInterval.js";
|
||||
import { addMinutes } from "./addMinutes.js";
|
||||
import { constructFrom } from "./constructFrom.js";
|
||||
|
||||
/**
|
||||
* The {@link eachMinuteOfInterval} function options.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The {@link eachMinuteOfInterval} 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 eachMinuteOfInterval
|
||||
* @category Interval Helpers
|
||||
@@ -16,7 +21,8 @@ var _index3 = require("./toDate.js");
|
||||
* @description
|
||||
* Returns the array of minutes 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.
|
||||
@@ -36,15 +42,14 @@ var _index3 = require("./toDate.js");
|
||||
* // Wed Oct 14 2014 13:03:00
|
||||
* // ]
|
||||
*/
|
||||
function eachMinuteOfInterval(interval, options) {
|
||||
const startDate = (0, _index2.startOfMinute)(
|
||||
(0, _index3.toDate)(interval.start),
|
||||
);
|
||||
const endDate = (0, _index3.toDate)(interval.end);
|
||||
export function eachMinuteOfInterval(interval, options) {
|
||||
const { start, end } = normalizeInterval(options?.in, interval);
|
||||
// Set to the start of the minute
|
||||
start.setSeconds(0, 0);
|
||||
|
||||
let reversed = +startDate > +endDate;
|
||||
const endTime = reversed ? +startDate : +endDate;
|
||||
let currentDate = reversed ? endDate : startDate;
|
||||
let reversed = +start > +end;
|
||||
const endTime = reversed ? +start : +end;
|
||||
let date = reversed ? end : start;
|
||||
|
||||
let step = options?.step ?? 1;
|
||||
if (!step) return [];
|
||||
@@ -55,10 +60,13 @@ function eachMinuteOfInterval(interval, options) {
|
||||
|
||||
const dates = [];
|
||||
|
||||
while (+currentDate <= endTime) {
|
||||
dates.push((0, _index3.toDate)(currentDate));
|
||||
currentDate = (0, _index.addMinutes)(currentDate, step);
|
||||
while (+date <= endTime) {
|
||||
dates.push(constructFrom(start, date));
|
||||
date = addMinutes(date, step);
|
||||
}
|
||||
|
||||
return reversed ? dates.reverse() : dates;
|
||||
}
|
||||
|
||||
// Fallback for modularized imports:
|
||||
export default eachMinuteOfInterval;
|
||||
|
||||
Reference in New Issue
Block a user