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,7 @@
"use strict";
exports.getWeeksInMonth = getWeeksInMonth;
var _index = require("./differenceInCalendarWeeks.js");
var _index2 = require("./lastDayOfMonth.js");
var _index3 = require("./startOfMonth.js");
import { differenceInCalendarWeeks } from "./differenceInCalendarWeeks.js";
import { lastDayOfMonth } from "./lastDayOfMonth.js";
import { startOfMonth } from "./startOfMonth.js";
import { toDate } from "./toDate.js";
/**
* The {@link getWeeksInMonth} function options.
@@ -16,8 +15,6 @@ var _index3 = require("./startOfMonth.js");
* @description
* Get the number of calendar weeks the month in the given date spans.
*
* @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.
*
@@ -34,12 +31,16 @@ var _index3 = require("./startOfMonth.js");
* const result = getWeeksInMonth(new Date(2017, 6, 5), { weekStartsOn: 1 })
* //=> 6
*/
function getWeeksInMonth(date, options) {
export function getWeeksInMonth(date, options) {
const contextDate = toDate(date, options?.in);
return (
(0, _index.differenceInCalendarWeeks)(
(0, _index2.lastDayOfMonth)(date),
(0, _index3.startOfMonth)(date),
differenceInCalendarWeeks(
lastDayOfMonth(contextDate, options),
startOfMonth(contextDate, options),
options,
) + 1
);
}
// Fallback for modularized imports:
export default getWeeksInMonth;