Skip to content
Snippets Groups Projects
Commit b8b5adba authored by Adam Laskowski's avatar Adam Laskowski
Browse files

SSDM-55: Refactored isDateValid function to avoid 'unknown variable error'

parent b44961b7
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
...@@ -504,22 +504,16 @@ var Util = new function() { ...@@ -504,22 +504,16 @@ var Util = new function() {
} }
this.isDateValid = function(dateAsString, isDateOnly) { this.isDateValid = function(dateAsString, isDateOnly) {
var result = {isValid : true};
if (dateAsString) { if (dateAsString) {
var timeValueObject = Util.parseDate(dateAsString); var timeValueObject = Util.parseDate(dateAsString);
if(timeValueObject.getFullYear() !== parseInt(dateAsString.substring(0,4))) { if(timeValueObject.getFullYear() !== parseInt(dateAsString.substring(0,4))) {
isValid = false; result.isValid = false;
error = "Incorrect Date Format. Please follow the format " + (isDateOnly ? 'yyyy-MM-dd (YEAR-MONTH-DAY)' : 'yyyy-MM-dd HH:mm:ss (YEAR-MONTH-DAY : HOUR-MINUTE-SECOND)') + "."; result.error = "Incorrect Date Format. Please follow the format " + (isDateOnly ? 'yyyy-MM-dd (YEAR-MONTH-DAY)' : 'yyyy-MM-dd HH:mm:ss (YEAR-MONTH-DAY : HOUR-MINUTE-SECOND)') + ".";
} else {
isValid = true;
} }
return {
isValid : isValid,
error : error
};
} }
return { isValid : true} return result;
} }
this.getFormatedDate = function(date) { this.getFormatedDate = function(date) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment