From edb11bc07d0c818d17d409d6e1302b0f02a9eb73 Mon Sep 17 00:00:00 2001 From: Christoph Dietze Date: Fri, 25 Jul 2014 10:28:22 +0200 Subject: [PATCH] fix(datepicker): don't fall back to parse using new Date(...) Fixes #2508 --- src/datepicker/datepicker.js | 2 +- src/datepicker/test/datepicker.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/datepicker/datepicker.js b/src/datepicker/datepicker.js index f8cdf1279f..d062eae32f 100644 --- a/src/datepicker/datepicker.js +++ b/src/datepicker/datepicker.js @@ -509,7 +509,7 @@ function ($compile, $parse, $document, $position, dateFilter, dateParser, datepi ngModel.$setValidity('date', true); return viewValue; } else if (angular.isString(viewValue)) { - var date = dateParser.parse(viewValue, dateFormat) || new Date(viewValue); + var date = dateParser.parse(viewValue, dateFormat); if (isNaN(date)) { ngModel.$setValidity('date', false); return undefined; diff --git a/src/datepicker/test/datepicker.spec.js b/src/datepicker/test/datepicker.spec.js index 1eb14a434d..1c2a884427 100644 --- a/src/datepicker/test/datepicker.spec.js +++ b/src/datepicker/test/datepicker.spec.js @@ -1171,7 +1171,7 @@ describe('datepicker directive', function () { }); it('updates the model & calendar when input value changes', function() { - changeInputValueTo(inputEl, 'March 5, 1980'); + changeInputValueTo(inputEl, '1980-03-05'); expect($rootScope.date.getFullYear()).toEqual(1980); expect($rootScope.date.getMonth()).toEqual(2);