diff --git a/src/datepicker/datepicker.js b/src/datepicker/datepicker.js index accdc08503..c1f67cb913 100644 --- a/src/datepicker/datepicker.js +++ b/src/datepicker/datepicker.js @@ -633,8 +633,9 @@ function(scope, element, attrs, $compile, $parse, $document, $rootScope, $positi if (!date) { date = new Date(value); if (angular.isDate(date) && !isNaN(date)) { - var dateArray = date.toISOString().split('T')[0].split('-'); + var dateArray = date.toJSON().split('T')[0].split('-'); date = new Date(+dateArray[0], +dateArray[1] - 1, +dateArray[2]); + date.setFullYear(+dateArray[0]); } } scope.watchData[key] = date; diff --git a/src/datepicker/test/datepicker.spec.js b/src/datepicker/test/datepicker.spec.js index 1b97feb9af..de3aed8f48 100644 --- a/src/datepicker/test/datepicker.spec.js +++ b/src/datepicker/test/datepicker.spec.js @@ -1950,8 +1950,8 @@ describe('datepicker directive', function() { it('should disable today button if before min date, literal case', function() { var minDate = new Date(new Date().setDate(new Date().getDate() + 1)); - var literalMinDate = minDate.toISOString().split('T')[0]; - var wrapElement = $compile('