Skip to content

Commit

Permalink
fix(calendar): date formatting when entered via keyboard
Browse files Browse the repository at this point in the history
This PR aim to fix (or at least drastically reduce) the broken date format when it's typed through keyboard. It's a bit hacky, since it only reverse supposed days and month when the setting monthFirst is defined to true, but I think this little piece of code will cover 98% of cases.

Closes #829 #986
  • Loading branch information
prudho authored and Sean committed Sep 6, 2019
1 parent b37e3fd commit 98f999f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/definitions/modules/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,8 @@ $.fn.calendar.settings = {
if (text.length === 0) {
return null;
}
// Reverse date and month in some cases
text = settings.monthFirst ? text : text.replace(/([0-9]+)[\/\-\.]([0-9]+)/,'$2/$1');
var textDate = new Date(text);
if(!isNaN(textDate.getDate())) {
return textDate;
Expand Down

0 comments on commit 98f999f

Please sign in to comment.