Changed return type of dateToW3CString in case of error; Changed the dependend chunk of code

This commit is contained in:
alexandercerutti
2018-08-23 23:33:00 +02:00
parent 09626f9885
commit 9c58529687

View File

@@ -199,11 +199,7 @@ class Pass {
return this; return this;
} }
const convDate = dateToW3CString(date); this.props.expirationDate = dateToW3CString(date);
if (convDate) {
this.props.expirationDate = convDate;
}
return this; return this;
} }
@@ -258,11 +254,7 @@ class Pass {
length: 1 length: 1
}, this); }, this);
} else if (type === "relevantDate") { } else if (type === "relevantDate") {
let convDate = dateToW3CString(data); this.props[type] = dateToW3CString(data);
if (convDate) {
this.props[type] = convDate;
}
return Object.assign({ return Object.assign({
length: Number(!!convDate) length: Number(!!convDate)
@@ -652,7 +644,9 @@ function isValidRGB(value) {
* Converts a date to W3C Standard format * Converts a date to W3C Standard format
* *
* @function dateToW3Cstring * @function dateToW3Cstring
* @params {String} * @params {String} - The date to be parsed
* @returns {String|undefined} The parsed string if the parameter is valid,
* undefined otherwise
*/ */
function dateToW3CString(date) { function dateToW3CString(date) {
@@ -663,7 +657,7 @@ function dateToW3CString(date) {
let parsedDate = moment(date, ["MM-DD-YYYY"]).format(); let parsedDate = moment(date, ["MM-DD-YYYY"]).format();
if (parsedDate === "Invalid date") { if (parsedDate === "Invalid date") {
return ""; return undefined;
} }
return parsedDate; return parsedDate;