@genexus/web-standard-functions
Version:
GeneXus JavaScript standard functions library for web generators
21 lines • 768 B
JavaScript
;
/**
* Returns the difference, in years, between the two parameters.
* If the second parameter, which is optional, is omitted, then the default value is the value returned by the function Today()
* @param {GxDate | GxDatetime} dateFrom
* @param {GxDate | GxDatetime} dateTo
* @return number
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.age = void 0;
const luxon_1 = require("luxon");
const today_1 = require("../date/today");
const age = (dateFrom, dateTo) => {
if (dateTo === undefined) {
dateTo = (0, today_1.today)();
}
return Math.trunc(luxon_1.DateTime.fromJSDate(dateTo).diff(luxon_1.DateTime.fromJSDate(dateFrom), "years")
.years);
};
exports.age = age;
//# sourceMappingURL=age.js.map