decord/source/3742_roundToNearestMinutes.js
2026-08-05 07:35:12 +00:00

69 lines
2 KiB
JavaScript

// Module ID: 3742
// Function ID: 3743
// Name: roundToNearestMinutes
// Dependencies: [3334, 3338, 3528]
// Exports: default
// Module 3742 (roundToNearestMinutes)
import _typeof from "_typeof";
import toInteger from "toInteger";
if (!_typeof) {
let obj = { default: null };
obj[0] = _typeof;
let tmp3 = obj;
} else {
tmp3 = _typeof;
}
if (!toInteger) {
obj = { default: null };
obj[0] = toInteger;
let tmp5 = obj;
} else {
tmp5 = toInteger;
}
let c3 = tmp5;
export default function roundToNearestMinutes(arg0, nearestTo) {
if (arguments.length < 1) {
const _TypeError = TypeError;
const typeError = new TypeError("1 argument required, but only none provided present");
throw typeError;
} else {
nearestTo = undefined;
if (null != nearestTo) {
nearestTo = nearestTo.nearestTo;
}
let num = 1;
if (null !== nearestTo) {
num = 1;
if (undefined !== nearestTo) {
num = nearestTo;
}
}
const defaultResult = tmp5.default(num);
if (defaultResult >= 1) {
if (defaultResult <= 30) {
const defaultResult1 = tmp3.default(arg0);
const seconds = defaultResult1.getSeconds();
const sum = defaultResult1.getMinutes() + seconds / 60;
let roundingMethod;
if (null != nearestTo) {
roundingMethod = nearestTo.roundingMethod;
}
const _Math = Math;
const result = require(3528) /* getRoundingMethod */.getRoundingMethod(roundingMethod)(sum / defaultResult) * defaultResult;
const _Date = Date;
const result1 = Math.round(sum % defaultResult / defaultResult) * defaultResult;
const fullYear = defaultResult1.getFullYear();
const month = defaultResult1.getMonth();
const date1 = new Date(fullYear, month, defaultResult1.getDate(), defaultResult1.getHours(), result + result1);
return date1;
}
}
const _RangeError = RangeError;
const rangeError = new RangeError("`options.nearestTo` must be between 1 and 30");
throw rangeError;
}
};
export default exports.default;