@progress/kendo-date-math
Version:
Kendo UI typescript package exporting functions for Date manipulations
20 lines (19 loc) • 755 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.durationInMonths = void 0;
/**
* A function that calculates duration in months between two `Date` objects.
*
* @param start - The start date value.
* @param end - The end date value.
* @returns - The duration in months.
*
* @example
* ```ts-no-run
* durationInMonths(new Date(2016, 0, 1), new Date(2017, 0, 1)); // 12
* durationInMonths(new Date(2016, 6, 1), new Date(2017, 0, 1)); // 6
* durationInMonths(new Date(2016, 0, 1), new Date(2016, 0, 1)); // 0
* ```
*/
var durationInMonths = function (start, end) { return (((end.getFullYear() - start.getFullYear())) * 12 + (end.getMonth() - start.getMonth())); };
exports.durationInMonths = durationInMonths;