[JS] the replace statement in parseDate is too greedy (#8632) (#8633)

* updated the regex used in the String.replace for parseDate() to more precisely target ISO-8601
* added the replace function call to the ES6 mustache file
This commit is contained in:
Troy P 2021-02-07 21:27:59 -08:00 committed by GitHub
parent ef9e8b7181
commit 75b987104b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 4 deletions

View File

@ -576,7 +576,7 @@
*/ */
{{/emitJSDoc}} exports.parseDate = function(str) { {{/emitJSDoc}} exports.parseDate = function(str) {
if (isNaN(str)) { if (isNaN(str)) {
return new Date(str.replace(/T/i, ' ')); return new Date(str.replace(/(\d)(T)(\d)/i, '$1 $3'));
} }
return new Date(+str); return new Date(+str);
}; };

View File

@ -556,7 +556,7 @@ class ApiClient {
*/{{/emitJSDoc}} */{{/emitJSDoc}}
static parseDate(str) { static parseDate(str) {
if (isNaN(str)) { if (isNaN(str)) {
return new Date(str); return new Date(str.replace(/(\d)(T)(\d)/i, '$1 $3'));
} }
return new Date(+str); return new Date(+str);
} }

View File

@ -512,7 +512,7 @@ class ApiClient {
*/ */
static parseDate(str) { static parseDate(str) {
if (isNaN(str)) { if (isNaN(str)) {
return new Date(str); return new Date(str.replace(/(\d)(T)(\d)/i, '$1 $3'));
} }
return new Date(+str); return new Date(+str);
} }

View File

@ -513,7 +513,7 @@ class ApiClient {
*/ */
static parseDate(str) { static parseDate(str) {
if (isNaN(str)) { if (isNaN(str)) {
return new Date(str); return new Date(str.replace(/(\d)(T)(\d)/i, '$1 $3'));
} }
return new Date(+str); return new Date(+str);
} }