Skip to content

Commit

Permalink
Prevent invalid date written into xml (#7321)
Browse files Browse the repository at this point in the history
* Prevent invalid date written into xml

* set invalid date prevention at the variable initiating place

* default date and check isValid
  • Loading branch information
wangf1122 authored Sep 22, 2023
1 parent dc68eea commit 50cfa4c
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,15 @@
var isDateTime = scope.value.indexOf("T") !== -1;
var tokens = scope.value.split("T");

scope.date = new Date(
moment(isDateTime ? tokens[0] : scope.value)
.utc()
.format()
);
// Default to empty string and prevent 'Invalid Date' string to xmlSnippet
scope.date = '';
if (moment(isDateTime ? tokens[0] : scope.value).isValid()) {
scope.date = new Date(
moment(isDateTime ? tokens[0] : scope.value)
.utc()
.format()
);
}

var time = tokens[1];

Expand Down

0 comments on commit 50cfa4c

Please sign in to comment.