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: timezone fix for literals tweaks
Browse files Browse the repository at this point in the history
* toISOString -> toJSON (equivalent)
* date.setYear fix
* fix test to capture date-format mismatch edge case in #3437
  • Loading branch information
davious committed Nov 9, 2015
1 parent b799c53 commit 495e91f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/datepicker/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/datepicker/test/datepicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<div><input ng-model="date" uib-datepicker-popup min-date="\'' + literalMinDate + '\'" is-open="true"><div>')($rootScope);
var literalMinDate = minDate.toJSON().split('T')[0];
var wrapElement = $compile('<div><input ng-model="date" uib-datepicker-popup="MM/dd/yyyy" min-date="\'' + literalMinDate + '\'" is-open="true"><div>')($rootScope);
$rootScope.$digest();
assignElements(wrapElement);
assignButtonBar();
Expand Down

0 comments on commit 495e91f

Please sign in to comment.