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,11 @@
"use strict";
exports.differenceInISOWeekYears = differenceInISOWeekYears;
var _index = require("./compareAsc.js");
var _index2 = require("./differenceInCalendarISOWeekYears.js");
var _index3 = require("./subISOWeekYears.js");
var _index4 = require("./toDate.js");
import { normalizeDates } from "./_lib/normalizeDates.js";
import { compareAsc } from "./compareAsc.js";
import { differenceInCalendarISOWeekYears } from "./differenceInCalendarISOWeekYears.js";
import { subISOWeekYears } from "./subISOWeekYears.js";
/**
* The {@link differenceInISOWeekYears} function options.
*/
/**
* @name differenceInISOWeekYears
@@ -15,10 +17,9 @@ var _index4 = 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 dateLeft - The later date
* @param dateRight - The earlier date
* @param laterDate - The later date
* @param earlierDate - The earlier date
* @param options - The options
*
* @returns The number of full ISO week-numbering years
*
@@ -28,25 +29,30 @@ var _index4 = require("./toDate.js");
* new Date(2012, 0, 1),
* new Date(2010, 0, 1)
* )
* //=> 1
* // => 1
*/
function differenceInISOWeekYears(dateLeft, dateRight) {
let _dateLeft = (0, _index4.toDate)(dateLeft);
const _dateRight = (0, _index4.toDate)(dateRight);
const sign = (0, _index.compareAsc)(_dateLeft, _dateRight);
const difference = Math.abs(
(0, _index2.differenceInCalendarISOWeekYears)(_dateLeft, _dateRight),
export function differenceInISOWeekYears(laterDate, earlierDate, options) {
const [laterDate_, earlierDate_] = normalizeDates(
options?.in,
laterDate,
earlierDate,
);
_dateLeft = (0, _index3.subISOWeekYears)(_dateLeft, sign * difference);
// Math.abs(diff in full ISO years - diff in calendar ISO years) === 1
// if last calendar ISO year is not full
// If so, result must be decreased by 1 in absolute value
const sign = compareAsc(laterDate_, earlierDate_);
const diff = Math.abs(
differenceInCalendarISOWeekYears(laterDate_, earlierDate_, options),
);
const adjustedDate = subISOWeekYears(laterDate_, sign * diff, options);
const isLastISOWeekYearNotFull = Number(
(0, _index.compareAsc)(_dateLeft, _dateRight) === -sign,
compareAsc(adjustedDate, earlierDate_) === -sign,
);
const result = sign * (difference - isLastISOWeekYearNotFull);
const result = sign * (diff - isLastISOWeekYearNotFull);
// Prevent negative zero
return result === 0 ? 0 : result;
}
// Fallback for modularized imports:
export default differenceInISOWeekYears;