UNPKG

@genexus/web-standard-functions

Version:

GeneXus JavaScript standard functions library for web generators

35 lines 1.22 kB
"use strict"; /** * Returns a Date from string value format espected format dd[/]mm[/]yyyy * @param {string} dateFrom * @param {string} dateFormat * @param {string} fy20c * @return GxDate */ Object.defineProperty(exports, "__esModule", { value: true }); exports.fromString = void 0; const gxdate_1 = require("../types/gxdate"); const core_1 = require("./core"); const newInstance_1 = require("./newInstance"); const fromString = (dateFrom, dateFormat, fy20c) => { if (!dateFormat) { dateFormat = "MDY"; } if (!fy20c) { fy20c = 40; } // Date Format dateFormat = “MDY” dateFormat = “DMY” dateFormat = “YMD” o Y4 let year = dateFormat.indexOf("Y"); let month = dateFormat.indexOf("M"); let day = dateFormat.indexOf("D"); let dateParts = dateFrom.split("/"); if (dateFormat.indexOf("Y4") === 0) { month = month - 1; day = day - 1; } return dateParts && dateParts.length > 2 ? (0, newInstance_1.newInstance)(Number(dateParts[year]), Number(dateParts[month]), Number(dateParts[day]), fy20c) : new gxdate_1.GxDate(core_1.EMPTY_DATE_VALUE); }; exports.fromString = fromString; //# sourceMappingURL=CtoD.js.map