@technobuddha/library
Version:
A large library of useful functions
19 lines (18 loc) • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.addTime = void 0;
/**
* Add units of time to a Date
*
* @remarks Negative values will subtract from the Date
*
* @param input Starting date
* @param __namedParameters Amount of time to increment
* @returns Adjusted date.
*/
function addTime(input, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.years, years = _c === void 0 ? 0 : _c, _d = _b.months, months = _d === void 0 ? 0 : _d, _e = _b.days, days = _e === void 0 ? 0 : _e, _f = _b.hours, hours = _f === void 0 ? 0 : _f, _g = _b.minutes, minutes = _g === void 0 ? 0 : _g, _h = _b.seconds, seconds = _h === void 0 ? 0 : _h, _j = _b.milliseconds, milliseconds = _j === void 0 ? 0 : _j;
return new Date(input.getFullYear() + years, input.getMonth() + months, input.getDate() + days, input.getHours() + hours, input.getMinutes() + minutes, input.getSeconds() + seconds, input.getMilliseconds() + milliseconds);
}
exports.addTime = addTime;
exports.default = addTime;