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,7 +1,5 @@
"use strict";
exports.setWeek = setWeek;
var _index = require("./getWeek.js");
var _index2 = require("./toDate.js");
import { getWeek } from "./getWeek.js";
import { toDate } from "./toDate.js";
/**
* The {@link setWeek} function options.
@@ -22,6 +20,7 @@ var _index2 = require("./toDate.js");
* Week numbering: https://en.wikipedia.org/wiki/Week#The_ISO_week_date_system
*
* @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 week - The week of the new date
@@ -44,9 +43,12 @@ var _index2 = require("./toDate.js");
* })
* //=> Sun Jan 4 2004 00:00:00
*/
function setWeek(date, week, options) {
const _date = (0, _index2.toDate)(date);
const diff = (0, _index.getWeek)(_date, options) - week;
_date.setDate(_date.getDate() - diff * 7);
return _date;
export function setWeek(date, week, options) {
const date_ = toDate(date, options?.in);
const diff = getWeek(date_, options) - week;
date_.setDate(date_.getDate() - diff * 7);
return toDate(date_, options?.in);
}
// Fallback for modularized imports:
export default setWeek;