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,18 @@
"use strict";
exports.eachWeekOfInterval = eachWeekOfInterval;
var _index = require("./addWeeks.js");
var _index2 = require("./startOfWeek.js");
var _index3 = require("./toDate.js");
import { normalizeInterval } from "./_lib/normalizeInterval.js";
import { addWeeks } from "./addWeeks.js";
import { constructFrom } from "./constructFrom.js";
import { startOfWeek } from "./startOfWeek.js";
/**
* The {@link eachWeekOfInterval} function options.
*/
/**
* The {@link eachWeekOfInterval} function result type. It resolves the proper data type.
* It uses the first argument date object type, starting from the interval start date,
* then the end interval date. If a context function is passed, it uses the context function return type.
*/
/**
* @name eachWeekOfInterval
* @category Interval Helpers
@@ -16,8 +21,6 @@ var _index3 = require("./toDate.js");
* @description
* Return the array of weeks 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).
*
* @param interval - The interval.
* @param options - An object with options.
*
@@ -40,19 +43,17 @@ var _index3 = require("./toDate.js");
* // Sun Nov 23 2014 00:00:00
* // ]
*/
function eachWeekOfInterval(interval, options) {
const startDate = (0, _index3.toDate)(interval.start);
const endDate = (0, _index3.toDate)(interval.end);
export function eachWeekOfInterval(interval, options) {
const { start, end } = normalizeInterval(options?.in, interval);
let reversed = +startDate > +endDate;
let reversed = +start > +end;
const startDateWeek = reversed
? (0, _index2.startOfWeek)(endDate, options)
: (0, _index2.startOfWeek)(startDate, options);
? startOfWeek(end, options)
: startOfWeek(start, options);
const endDateWeek = reversed
? (0, _index2.startOfWeek)(startDate, options)
: (0, _index2.startOfWeek)(endDate, options);
? startOfWeek(start, options)
: startOfWeek(end, options);
// Some timezones switch DST at midnight, making start of day unreliable in these timezones, 3pm is a safe bet
startDateWeek.setHours(15);
endDateWeek.setHours(15);
@@ -70,10 +71,13 @@ function eachWeekOfInterval(interval, options) {
while (+currentDate <= endTime) {
currentDate.setHours(0);
dates.push((0, _index3.toDate)(currentDate));
currentDate = (0, _index.addWeeks)(currentDate, step);
dates.push(constructFrom(start, currentDate));
currentDate = addWeeks(currentDate, step);
currentDate.setHours(15);
}
return reversed ? dates.reverse() : dates;
}
// Fallback for modularized imports:
export default eachWeekOfInterval;