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.getISOWeekYear = getISOWeekYear;
var _index = require("./constructFrom.js");
var _index2 = require("./startOfISOWeek.js");
var _index3 = require("./toDate.js");
import { constructFrom } from "./constructFrom.js";
import { startOfISOWeek } from "./startOfISOWeek.js";
import { toDate } from "./toDate.js";
/**
* The {@link getISOWeekYear} function options.
*/
/**
* @name getISOWeekYear
@@ -15,8 +17,6 @@ var _index3 = require("./toDate.js");
*
* ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
*
* @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
*
* @returns The ISO week-numbering year
@@ -26,23 +26,19 @@ var _index3 = require("./toDate.js");
* const result = getISOWeekYear(new Date(2005, 0, 2))
* //=> 2004
*/
function getISOWeekYear(date) {
const _date = (0, _index3.toDate)(date);
export function getISOWeekYear(date, options) {
const _date = toDate(date, options?.in);
const year = _date.getFullYear();
const fourthOfJanuaryOfNextYear = (0, _index.constructFrom)(date, 0);
const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
const startOfNextYear = (0, _index2.startOfISOWeek)(
fourthOfJanuaryOfNextYear,
);
const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
const fourthOfJanuaryOfThisYear = (0, _index.constructFrom)(date, 0);
const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
const startOfThisYear = (0, _index2.startOfISOWeek)(
fourthOfJanuaryOfThisYear,
);
const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
if (_date.getTime() >= startOfNextYear.getTime()) {
return year + 1;
@@ -52,3 +48,6 @@ function getISOWeekYear(date) {
return year - 1;
}
}
// Fallback for modularized imports:
export default getISOWeekYear;