decord/source/3617_roundToNearestMinutes.js

55 lines
1.8 KiB
JavaScript
Raw Normal View History

2026-07-23 10:11:24 +00:00
// Module ID: 3617
2026-07-24 07:16:23 +00:00
// Function ID: 27853
2026-07-20 16:05:17 +00:00
// Name: roundToNearestMinutes
2026-07-23 10:11:24 +00:00
// Dependencies: [3209, 3213, 3403]
2026-07-20 16:05:17 +00:00
// Exports: default
2026-07-23 10:11:24 +00:00
// Module 3617 (roundToNearestMinutes)
import _typeof from "_typeof";
import toInteger from "toInteger";
2026-07-20 16:05:17 +00:00
export default function roundToNearestMinutes(defaultResult1, 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;
}
}
2026-07-23 10:11:24 +00:00
const defaultResult = toInteger.default(num);
2026-07-20 16:05:17 +00:00
if (defaultResult >= 1) {
if (defaultResult <= 30) {
2026-07-23 10:11:24 +00:00
defaultResult1 = _typeof.default(defaultResult1);
2026-07-20 16:05:17 +00:00
const seconds = defaultResult1.getSeconds();
const sum = defaultResult1.getMinutes() + seconds / 60;
let roundingMethod;
if (null != nearestTo) {
roundingMethod = nearestTo.roundingMethod;
}
const _Math = Math;
2026-07-23 10:11:24 +00:00
const result = require(3403) /* getRoundingMethod */.getRoundingMethod(roundingMethod)(sum / defaultResult) * defaultResult;
2026-07-20 16:05:17 +00:00
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;