adding handling for epoch dates in javascript ApiClient mustache file (#6497) (#6504)

This commit is contained in:
Troy P 2020-08-04 08:55:38 -07:00 committed by GitHub
parent c1b53df345
commit 9f1d012d14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 8 deletions

View File

@ -541,12 +541,15 @@
{{/usePromises}} };
{{#emitJSDoc}} /**
* Parses an ISO-8601 string representation of a date value.
* Parses an ISO-8601 string representation or epoch representation of a date value.
* @param {String} str The date value as a string.
* @returns {Date} The parsed date object.
*/
{{/emitJSDoc}} exports.parseDate = function(str) {
if (isNaN(str)) {
return new Date(str.replace(/T/i, ' '));
}
return new Date(+str);
};
{{#emitJSDoc}} /**

View File

@ -519,13 +519,16 @@ class ApiClient {
}
{{#emitJSDoc}}/**
* Parses an ISO-8601 string representation of a date value.
* Parses an ISO-8601 string representation or epoch representation of a date value.
* @param {String} str The date value as a string.
* @returns {Date} The parsed date object.
*/{{/emitJSDoc}}
static parseDate(str) {
if (isNaN(str)) {
return new Date(str);
}
return new Date(+str);
}
{{#emitJSDoc}}/**
* Converts a value to the specified type.

View File

@ -475,13 +475,16 @@ class ApiClient {
}
/**
* Parses an ISO-8601 string representation of a date value.
* Parses an ISO-8601 string representation or epoch representation of a date value.
* @param {String} str The date value as a string.
* @returns {Date} The parsed date object.
*/
static parseDate(str) {
if (isNaN(str)) {
return new Date(str);
}
return new Date(+str);
}
/**
* Converts a value to the specified type.

View File

@ -476,13 +476,16 @@ class ApiClient {
}
/**
* Parses an ISO-8601 string representation of a date value.
* Parses an ISO-8601 string representation or epoch representation of a date value.
* @param {String} str The date value as a string.
* @returns {Date} The parsed date object.
*/
static parseDate(str) {
if (isNaN(str)) {
return new Date(str);
}
return new Date(+str);
}
/**
* Converts a value to the specified type.