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

Commit 495e91f

Browse files
committed
fix(datepicker): min-date: timezone fix for literals tweaks
* toISOString -> toJSON (equivalent) * date.setYear fix * fix test to capture date-format mismatch edge case in #3437
1 parent b799c53 commit 495e91f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Diff for: src/datepicker/datepicker.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,9 @@ function(scope, element, attrs, $compile, $parse, $document, $rootScope, $positi
633633
if (!date) {
634634
date = new Date(value);
635635
if (angular.isDate(date) && !isNaN(date)) {
636-
var dateArray = date.toISOString().split('T')[0].split('-');
636+
var dateArray = date.toJSON().split('T')[0].split('-');
637637
date = new Date(+dateArray[0], +dateArray[1] - 1, +dateArray[2]);
638+
date.setFullYear(+dateArray[0]);
638639
}
639640
}
640641
scope.watchData[key] = date;

Diff for: src/datepicker/test/datepicker.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1950,8 +1950,8 @@ describe('datepicker directive', function() {
19501950

19511951
it('should disable today button if before min date, literal case', function() {
19521952
var minDate = new Date(new Date().setDate(new Date().getDate() + 1));
1953-
var literalMinDate = minDate.toISOString().split('T')[0];
1954-
var wrapElement = $compile('<div><input ng-model="date" uib-datepicker-popup min-date="\'' + literalMinDate + '\'" is-open="true"><div>')($rootScope);
1953+
var literalMinDate = minDate.toJSON().split('T')[0];
1954+
var wrapElement = $compile('<div><input ng-model="date" uib-datepicker-popup="MM/dd/yyyy" min-date="\'' + literalMinDate + '\'" is-open="true"><div>')($rootScope);
19551955
$rootScope.$digest();
19561956
assignElements(wrapElement);
19571957
assignButtonBar();

0 commit comments

Comments
 (0)