Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(datepicker): min-date/max-date: parse fix for literals
Browse files Browse the repository at this point in the history
BREAKING CHANGE: only display formats or altInputFormats are valid for literal dates

Closes #3437
  • Loading branch information
davious committed Nov 27, 2015
1 parent 8bfeda0 commit 8aaa918
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/datepicker/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,10 +628,10 @@ function(scope, element, attrs, $compile, $parse, $document, $rootScope, $positi
if (attrs[key]) {
var getAttribute = $parse(attrs[key]);
scope.$parent.$watch(getAttribute, function(value) {
scope.watchData[key] = value;
if (key === 'minDate' || key === 'maxDate') {
cache[key] = new Date(value);
cache[key] = new Date(parseDate(value));
}
scope.watchData[key] = cache[key] || value;
});
datepickerEl.attr(cameltoDash(key), 'watchData.' + key);

Expand Down
11 changes: 11 additions & 0 deletions src/datepicker/test/datepicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1982,6 +1982,17 @@ describe('datepicker', function() {
expect(buttons.eq(0).prop('disabled')).toBe(true);
});

it('should disable today button if before min date, yyyy-MM-dd case', inject(function($filter) {
var minDate = new Date(new Date().setDate(new Date().getDate() + 1));
var literalMinDate = $filter('date')(minDate, 'yyyy-MM-dd');
var wrapElement = $compile('<div><input ng-model="date" uib-datepicker-popup="yyyy-MM-dd" min-date="\'' + literalMinDate + '\'" is-open="true"><div>')($rootScope);
$rootScope.$digest();
assignElements(wrapElement);
assignButtonBar();

expect(buttons.eq(0).prop('disabled')).toBe(true);
}));

it('should disable today button if after max date', function() {
$rootScope.maxDate = new Date().setDate(new Date().getDate() - 2);
var wrapElement = $compile('<div><input ng-model="date" uib-datepicker-popup max-date="maxDate" is-open="true"><div>')($rootScope);
Expand Down

0 comments on commit 8aaa918

Please sign in to comment.