registration
This commit is contained in:
38
frontend/style/node_modules/date-fns/eachHourOfInterval.js
generated
vendored
38
frontend/style/node_modules/date-fns/eachHourOfInterval.js
generated
vendored
@@ -1,12 +1,15 @@
|
||||
"use strict";
|
||||
exports.eachHourOfInterval = eachHourOfInterval;
|
||||
var _index = require("./addHours.js");
|
||||
var _index2 = require("./toDate.js");
|
||||
import { normalizeInterval } from "./_lib/normalizeInterval.js";
|
||||
import { constructFrom } from "./constructFrom.js";
|
||||
|
||||
/**
|
||||
* The {@link eachHourOfInterval} function options.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The {@link eachHourOfInterval} function result type.
|
||||
* Resolves to the appropriate date type based on inputs.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name eachHourOfInterval
|
||||
* @category Interval Helpers
|
||||
@@ -15,7 +18,8 @@ var _index2 = require("./toDate.js");
|
||||
* @description
|
||||
* Return the array of hours 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.
|
||||
@@ -27,7 +31,7 @@ var _index2 = require("./toDate.js");
|
||||
* const result = eachHourOfInterval({
|
||||
* start: new Date(2014, 9, 6, 12),
|
||||
* end: new Date(2014, 9, 6, 15)
|
||||
* })
|
||||
* });
|
||||
* //=> [
|
||||
* // Mon Oct 06 2014 12:00:00,
|
||||
* // Mon Oct 06 2014 13:00:00,
|
||||
@@ -35,14 +39,13 @@ var _index2 = require("./toDate.js");
|
||||
* // Mon Oct 06 2014 15:00:00
|
||||
* // ]
|
||||
*/
|
||||
function eachHourOfInterval(interval, options) {
|
||||
const startDate = (0, _index2.toDate)(interval.start);
|
||||
const endDate = (0, _index2.toDate)(interval.end);
|
||||
export function eachHourOfInterval(interval, options) {
|
||||
const { start, end } = normalizeInterval(options?.in, interval);
|
||||
|
||||
let reversed = +startDate > +endDate;
|
||||
const endTime = reversed ? +startDate : +endDate;
|
||||
let currentDate = reversed ? endDate : startDate;
|
||||
currentDate.setMinutes(0, 0, 0);
|
||||
let reversed = +start > +end;
|
||||
const endTime = reversed ? +start : +end;
|
||||
const date = reversed ? end : start;
|
||||
date.setMinutes(0, 0, 0);
|
||||
|
||||
let step = options?.step ?? 1;
|
||||
if (!step) return [];
|
||||
@@ -53,10 +56,13 @@ function eachHourOfInterval(interval, options) {
|
||||
|
||||
const dates = [];
|
||||
|
||||
while (+currentDate <= endTime) {
|
||||
dates.push((0, _index2.toDate)(currentDate));
|
||||
currentDate = (0, _index.addHours)(currentDate, step);
|
||||
while (+date <= endTime) {
|
||||
dates.push(constructFrom(start, date));
|
||||
date.setHours(date.getHours() + step);
|
||||
}
|
||||
|
||||
return reversed ? dates.reverse() : dates;
|
||||
}
|
||||
|
||||
// Fallback for modularized imports:
|
||||
export default eachHourOfInterval;
|
||||
|
||||
Reference in New Issue
Block a user