decord/source/3494_getWeekOfMonth.js

87 lines
2.4 KiB
JavaScript
Raw Normal View History

2026-07-25 08:10:48 +00:00
// Module ID: 3494
// Function ID: 26921
2026-07-20 16:05:17 +00:00
// Name: getWeekOfMonth
2026-07-25 08:10:48 +00:00
// Dependencies: [3472, 3473, 3426, 3211, 3214, 3215]
2026-07-20 16:05:17 +00:00
// Exports: default
2026-07-25 08:10:48 +00:00
// Module 3494 (getWeekOfMonth)
2026-07-23 10:11:24 +00:00
import getDate from "getDate";
import getDay from "getDay";
import startOfMonth from "startOfMonth";
import requiredArgs from "requiredArgs";
import toInteger from "toInteger";
2026-07-20 16:05:17 +00:00
export default function getWeekOfMonth(defaultResult1, weekStartsOn) {
2026-07-23 10:11:24 +00:00
requiredArgs.default(1, arguments);
2026-07-25 08:10:48 +00:00
const defaultOptions = require(3215) /* getDefaultOptions */.getDefaultOptions();
2026-07-20 16:05:17 +00:00
weekStartsOn = undefined;
if (null != weekStartsOn) {
weekStartsOn = weekStartsOn.weekStartsOn;
}
if (null === weekStartsOn) {
let weekStartsOn1;
if (null != weekStartsOn) {
const locale = weekStartsOn.locale;
if (null !== locale) {
if (undefined !== locale) {
const options = locale.options;
if (null !== options) {
if (undefined !== options) {
weekStartsOn1 = options.weekStartsOn;
}
}
}
}
}
weekStartsOn = weekStartsOn1;
}
if (null === weekStartsOn) {
weekStartsOn = defaultOptions.weekStartsOn;
}
if (null === weekStartsOn) {
const locale2 = defaultOptions.locale;
let weekStartsOn2;
if (null !== locale2) {
if (undefined !== locale2) {
const options2 = locale2.options;
if (null !== options2) {
if (undefined !== options2) {
weekStartsOn2 = options2.weekStartsOn;
}
}
}
}
weekStartsOn = weekStartsOn2;
}
let num = 0;
if (null !== weekStartsOn) {
num = 0;
if (undefined !== weekStartsOn) {
num = weekStartsOn;
}
}
2026-07-23 10:11:24 +00:00
defaultResult1 = toInteger.default(num);
2026-07-20 16:05:17 +00:00
if (defaultResult1 >= 0) {
if (defaultResult1 <= 6) {
2026-07-23 10:11:24 +00:00
const defaultResult2 = getDate.default(defaultResult1);
2026-07-20 16:05:17 +00:00
const _isNaN = isNaN;
if (isNaN(defaultResult2)) {
const _NaN = NaN;
return NaN;
} else {
2026-07-23 10:11:24 +00:00
const diff = defaultResult1 - getDay.default(startOfMonth.default(defaultResult1));
2026-07-20 16:05:17 +00:00
let sum = diff;
if (diff <= 0) {
sum = diff + 7;
}
const _Math = Math;
return Math.ceil((defaultResult2 - sum) / 7) + 1;
}
}
}
const rangeError = new RangeError("weekStartsOn must be between 0 and 6 inclusively");
throw rangeError;
};
export default exports.default;