mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-10 01:52:22 +03:00
Check provided date
This commit is contained in:
parent
ce40aa342b
commit
0da88a7729
1 changed files with 8 additions and 3 deletions
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue