From 0da88a7729adc0b1f725d39dbfe2b267e54fdf06 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sat, 12 Dec 2020 15:11:33 +0200 Subject: [PATCH] Check provided date --- assets/js/general_functions.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/assets/js/general_functions.js b/assets/js/general_functions.js index 231ce7cc..235120d1 100755 --- a/assets/js/general_functions.js +++ b/assets/js/general_functions.js @@ -365,16 +365,21 @@ window.GeneralFunctions = window.GeneralFunctions || {}; var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm'; var hours = addHours ? ' ' + timeFormat : ''; var result; + var parsedDate = Date.parse(date); + + if (!parsedDate) { + return date; + } switch (dateFormatSetting) { case 'DMY': - result = Date.parse(date).toString('dd/MM/yyyy' + hours); + result = parsedDate.toString('dd/MM/yyyy' + hours); break; case 'MDY': - result = Date.parse(date).toString('MM/dd/yyyy' + hours); + result = parsedDate.toString('MM/dd/yyyy' + hours); break; case 'YMD': - result = Date.parse(date).toString('yyyy/MM/dd' + hours); + result = parsedDate.toString('yyyy/MM/dd' + hours); break; default: throw new Error('Invalid date format setting provided!', dateFormatSetting);