UNPKG

@jsbits/add-months

Version:

Adds or subtracts N months to any JavaScript Date, local or UTC.

29 lines 1.26 kB
/** * Returns a date occurring `count` months after `startdate` or, if `count` is * negative, the date occurring `count` months before `startdate`. * * - If `startdate` is not a Date or number that can be converted to a * valid date, returns a new Date instance with an invalid date. * * - If `count` is evaluated as zero, returns a new Date instance with the * the same value as `startdate`. * * - If there is an overflow in the day, the date is adjusted to the last * valid day of the expected month. * * The third parameter is optional and indicates if the date is UTC. It is * necessary to differentiate UTC dates from locals and avoid errors due to the * [Daylight Saving Time](https://en.wikipedia.org/wiki/Daylight_saving_time) * (DST). * * This function does not change the original date. * * @param {Date|number} startdate A value parseable as a JavaScript Date * @param {number} count Number of months to add or subtract * @param {boolean} [asUTC=false] If `true`, handle the date as UTC * @returns {Date} A new, adjusted Date instance. * @since 1.0.0 */ declare const addMonths: (startdate: number | Date, count: number, asUTC?: boolean | undefined) => Date; export = addMonths; //# sourceMappingURL=index.d.ts.map