registration
This commit is contained in:
50
frontend/style/node_modules/date-fns/differenceInCalendarWeeks.js
generated
vendored
50
frontend/style/node_modules/date-fns/differenceInCalendarWeeks.js
generated
vendored
@@ -1,9 +1,7 @@
|
||||
"use strict";
|
||||
exports.differenceInCalendarWeeks = differenceInCalendarWeeks;
|
||||
var _index = require("./constants.js");
|
||||
var _index2 = require("./startOfWeek.js");
|
||||
|
||||
var _index3 = require("./_lib/getTimezoneOffsetInMilliseconds.js");
|
||||
import { getTimezoneOffsetInMilliseconds } from "./_lib/getTimezoneOffsetInMilliseconds.js";
|
||||
import { normalizeDates } from "./_lib/normalizeDates.js";
|
||||
import { millisecondsInWeek } from "./constants.js";
|
||||
import { startOfWeek } from "./startOfWeek.js";
|
||||
|
||||
/**
|
||||
* The {@link differenceInCalendarWeeks} function options.
|
||||
@@ -17,10 +15,8 @@ var _index3 = require("./_lib/getTimezoneOffsetInMilliseconds.js");
|
||||
* @description
|
||||
* Get the number of calendar weeks between the given dates.
|
||||
*
|
||||
* @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 - An object with options.
|
||||
*
|
||||
* @returns The number of calendar weeks
|
||||
@@ -43,21 +39,23 @@ var _index3 = require("./_lib/getTimezoneOffsetInMilliseconds.js");
|
||||
* )
|
||||
* //=> 2
|
||||
*/
|
||||
function differenceInCalendarWeeks(dateLeft, dateRight, options) {
|
||||
const startOfWeekLeft = (0, _index2.startOfWeek)(dateLeft, options);
|
||||
const startOfWeekRight = (0, _index2.startOfWeek)(dateRight, options);
|
||||
|
||||
const timestampLeft =
|
||||
+startOfWeekLeft -
|
||||
(0, _index3.getTimezoneOffsetInMilliseconds)(startOfWeekLeft);
|
||||
const timestampRight =
|
||||
+startOfWeekRight -
|
||||
(0, _index3.getTimezoneOffsetInMilliseconds)(startOfWeekRight);
|
||||
|
||||
// Round the number of days to the nearest integer because the number of
|
||||
// milliseconds in a days is not constant (e.g. it's different in the week of
|
||||
// the daylight saving time clock shift).
|
||||
return Math.round(
|
||||
(timestampLeft - timestampRight) / _index.millisecondsInWeek,
|
||||
export function differenceInCalendarWeeks(laterDate, earlierDate, options) {
|
||||
const [laterDate_, earlierDate_] = normalizeDates(
|
||||
options?.in,
|
||||
laterDate,
|
||||
earlierDate,
|
||||
);
|
||||
|
||||
const laterStartOfWeek = startOfWeek(laterDate_, options);
|
||||
const earlierStartOfWeek = startOfWeek(earlierDate_, options);
|
||||
|
||||
const laterTimestamp =
|
||||
+laterStartOfWeek - getTimezoneOffsetInMilliseconds(laterStartOfWeek);
|
||||
const earlierTimestamp =
|
||||
+earlierStartOfWeek - getTimezoneOffsetInMilliseconds(earlierStartOfWeek);
|
||||
|
||||
return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInWeek);
|
||||
}
|
||||
|
||||
// Fallback for modularized imports:
|
||||
export default differenceInCalendarWeeks;
|
||||
|
||||
Reference in New Issue
Block a user