UNPKG

@technobuddha/library

Version:
14 lines (13 loc) 597 B
/** * 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. */ export function addTime(input, { years = 0, months = 0, days = 0, hours = 0, minutes = 0, seconds = 0, milliseconds = 0 } = {}) { return new Date(input.getFullYear() + years, input.getMonth() + months, input.getDate() + days, input.getHours() + hours, input.getMinutes() + minutes, input.getSeconds() + seconds, input.getMilliseconds() + milliseconds); } export default addTime;