diff --git a/src/dateparser/dateparser.js b/src/dateparser/dateparser.js index eb323623b6..fea1b50d75 100644 --- a/src/dateparser/dateparser.js +++ b/src/dateparser/dateparser.js @@ -125,7 +125,7 @@ angular.module('ui.bootstrap.dateparser', []) if ( results && results.length ) { var fields, dt; - if (baseDate) { + if (angular.isDate(baseDate) && !isNaN(baseDate.getTime())) { fields = { year: baseDate.getFullYear(), month: baseDate.getMonth(), diff --git a/src/datepicker/datepicker.js b/src/datepicker/datepicker.js index a98b48dc7e..deba93ff4d 100644 --- a/src/datepicker/datepicker.js +++ b/src/datepicker/datepicker.js @@ -650,7 +650,7 @@ function ($compile, $parse, $document, $position, dateFilter, dateParser, datepi // Detect changes in the view from the text box ngModel.$viewChangeListeners.push(function () { - scope.date = dateParser.parse(ngModel.$viewValue, dateFormat, scope.date) || new Date(ngModel.$viewValue); + scope.date = dateParser.parse(ngModel.$viewValue, dateFormat, scope.date); }); var documentClickBind = function(event) {