Skip to content

Commit c96ba01

Browse files
authored
fix(calendar): fix timezone issue when time is not given
1 parent b3be317 commit c96ba01

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/definitions/modules/calendar.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,16 +1342,20 @@ $.fn.calendar.settings = {
13421342
if (!text) {
13431343
return null;
13441344
}
1345-
text = ('' + text).trim().toLowerCase();
1345+
text = String(text).trim();
13461346
if (text.length === 0) {
13471347
return null;
13481348
}
1349+
if(text.match(/^[0-9]{4}[\/\-\.][0-9]{2}[\/\-\.][0-9]{2}$/)){
1350+
text += ' 00:00:00';
1351+
}
13491352
// Reverse date and month in some cases
1350-
text = settings.monthFirst ? text : text.replace(/[\/\-\.]/g,'/').replace(/([0-9]+)\/([0-9]+)/,'$2/$1');
1353+
text = settings.monthFirst || !text.match(/^[0-9]{2}[\/\-\.]/) ? text : text.replace(/[\/\-\.]/g,'/').replace(/([0-9]+)\/([0-9]+)/,'$2/$1');
13511354
var textDate = new Date(text);
13521355
if(!isNaN(textDate.getDate())) {
13531356
return textDate;
13541357
}
1358+
text = text.toLowerCase();
13551359

13561360
var i, j, k;
13571361
var minute = -1, hour = -1, day = -1, month = -1, year = -1;

0 commit comments

Comments
 (0)