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,9 +1,7 @@
"use strict";
exports.getWeek = getWeek;
var _index = require("./constants.js");
var _index2 = require("./startOfWeek.js");
var _index3 = require("./startOfWeekYear.js");
var _index4 = require("./toDate.js");
import { millisecondsInWeek } from "./constants.js";
import { startOfWeek } from "./startOfWeek.js";
import { startOfWeekYear } from "./startOfWeekYear.js";
import { toDate } from "./toDate.js";
/**
* The {@link getWeek} function options.
@@ -23,8 +21,6 @@ var _index4 = 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).
*
* @param date - The given date
* @param options - An object with options
*
@@ -45,15 +41,15 @@ var _index4 = require("./toDate.js");
* })
* //=> 53
*/
function getWeek(date, options) {
const _date = (0, _index4.toDate)(date);
const diff =
+(0, _index2.startOfWeek)(_date, options) -
+(0, _index3.startOfWeekYear)(_date, options);
export function getWeek(date, options) {
const _date = toDate(date, options?.in);
const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
// Round the number of weeks to the nearest integer because the number of
// milliseconds in a week is not constant (e.g. it's different in the week of
// the daylight saving time clock shift).
return Math.round(diff / _index.millisecondsInWeek) + 1;
return Math.round(diff / millisecondsInWeek) + 1;
}
// Fallback for modularized imports:
export default getWeek;