From 7d8881f25bd1e31f8ca5b63e2533264b7c6df60f Mon Sep 17 00:00:00 2001 From: Ibragimov Ruslan Date: Mon, 20 Jul 2015 14:23:35 +0300 Subject: [PATCH] Fix for: https://github.com/angular-ui/bootstrap/issues/3701 --- src/dateparser/dateparser.js | 2 +- src/datepicker/datepicker.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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) {