UNPKG

@genexus/web-standard-functions

Version:

GeneXus JavaScript standard functions library for web generators

17 lines 625 B
/** * 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 */ import { DateTime } from "luxon"; import { today } from "../date/today"; export const age = (dateFrom, dateTo) => { if (dateTo === undefined) { dateTo = today(); } return Math.trunc(DateTime.fromJSDate(dateTo).diff(DateTime.fromJSDate(dateFrom), "years") .years); }; //# sourceMappingURL=age.js.map