diff --git a/src/structure/client/Resolver.js b/src/structure/client/Resolver.js index ab90452..758550e 100644 --- a/src/structure/client/Resolver.js +++ b/src/structure/client/Resolver.js @@ -63,10 +63,13 @@ class Resolver { resolveDate(string) { let date = null; - const matches = string.match(/([0-9]{4}(?:\/|-)[0-9]{1,2}(?:\/|-)[0-9]{1,2})/gimu); //YYYY-MM-DD is REQUIRED. - if (matches && matches.length > 0) { + const match = string.match(/((?[0-9]{4})(?:\/|-)(?[0-9]{1,2})(?:\/|-)(?[0-9]{1,2}))/imu); //YYYY-MM-DD is REQUIRED. + if (match) { + const { groups: { year, month, day } } = match; + const _month = month.length === 1 ? `0${month}` : month; + const _day = day.length === 1 ? `0${day}` : day; + const string = `${year}-${_month}-${_day}`; try { - const string = matches[0].replace(/\//giu, '-'); date = moment(string); } catch (error) { return null;