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,8 +1,10 @@
"use strict";
exports.setISODay = setISODay;
var _index = require("./addDays.js");
var _index2 = require("./getISODay.js");
var _index3 = require("./toDate.js");
import { addDays } from "./addDays.js";
import { getISODay } from "./getISODay.js";
import { toDate } from "./toDate.js";
/**
* The {@link setISODay} function options.
*/
/**
* @name setISODay
@@ -12,12 +14,14 @@ var _index3 = require("./toDate.js");
* @description
* Set the day of the ISO week to the given date.
* ISO week starts with Monday.
* 7 is the index of Sunday, 1 is the index of Monday etc.
* 7 is the index of Sunday, 1 is the index of Monday, etc.
*
* @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 ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param day - The day of the ISO week of the new date
* @param options - An object with options
*
* @returns The new date with the day of the ISO week set
*
@@ -26,9 +30,12 @@ var _index3 = require("./toDate.js");
* const result = setISODay(new Date(2014, 8, 1), 7)
* //=> Sun Sep 07 2014 00:00:00
*/
function setISODay(date, day) {
const _date = (0, _index3.toDate)(date);
const currentDay = (0, _index2.getISODay)(_date);
export function setISODay(date, day, options) {
const date_ = toDate(date, options?.in);
const currentDay = getISODay(date_, options);
const diff = day - currentDay;
return (0, _index.addDays)(_date, diff);
return addDays(date_, diff, options);
}
// Fallback for modularized imports:
export default setISODay;