Check provided date

This commit is contained in:
Alex Tselegidis 2020-12-12 15:11:33 +02:00
parent ce40aa342b
commit 0da88a7729

View file

@ -365,16 +365,21 @@ window.GeneralFunctions = window.GeneralFunctions || {};
var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm'; var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm';
var hours = addHours ? ' ' + timeFormat : ''; var hours = addHours ? ' ' + timeFormat : '';
var result; var result;
var parsedDate = Date.parse(date);
if (!parsedDate) {
return date;
}
switch (dateFormatSetting) { switch (dateFormatSetting) {
case 'DMY': case 'DMY':
result = Date.parse(date).toString('dd/MM/yyyy' + hours); result = parsedDate.toString('dd/MM/yyyy' + hours);
break; break;
case 'MDY': case 'MDY':
result = Date.parse(date).toString('MM/dd/yyyy' + hours); result = parsedDate.toString('MM/dd/yyyy' + hours);
break; break;
case 'YMD': case 'YMD':
result = Date.parse(date).toString('yyyy/MM/dd' + hours); result = parsedDate.toString('yyyy/MM/dd' + hours);
break; break;
default: default:
throw new Error('Invalid date format setting provided!', dateFormatSetting); throw new Error('Invalid date format setting provided!', dateFormatSetting);