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

Commit fbd0845

Browse files
committed
fix(datepickerPopup): correctly format to timezone
- Format according to ngModelOptions timezone if specified Closes #6159 Fixes #6105 Fixes #6146 Fixes #6147
1 parent 5597e2f commit fbd0845

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/datepickerPopup/popup.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $
3232

3333
this.init = function(_ngModel_) {
3434
ngModel = _ngModel_;
35-
ngModelOptions = _ngModel_.$options;
35+
ngModelOptions = angular.isObject(_ngModel_.$options) ?
36+
_ngModel_.$options :
37+
{
38+
timezone: null
39+
};
3640
closeOnDateSelection = angular.isDefined($attrs.closeOnDateSelection) ?
3741
$scope.$parent.$eval($attrs.closeOnDateSelection) :
3842
datepickerPopupConfig.closeOnDateSelection;
@@ -123,13 +127,13 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $
123127
value = new Date(value);
124128
}
125129

126-
$scope.date = value;
130+
$scope.date = dateParser.fromTimezone(value, ngModelOptions.timezone);
127131

128132
return dateParser.filter($scope.date, dateFormat);
129133
});
130134
} else {
131135
ngModel.$formatters.push(function(value) {
132-
$scope.date = value;
136+
$scope.date = dateParser.fromTimezone(value, ngModelOptions.timezone);
133137
return value;
134138
});
135139
}
@@ -181,7 +185,7 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $
181185

182186
$scope.isDisabled = function(date) {
183187
if (date === 'today') {
184-
date = new Date();
188+
date = dateParser.fromTimezone(new Date(), ngModelOptions.timezone);
185189
}
186190

187191
var dates = {};
@@ -328,7 +332,7 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $
328332
if (angular.isString(viewValue)) {
329333
var date = parseDateString(viewValue);
330334
if (!isNaN(date)) {
331-
return date;
335+
return dateParser.fromTimezone(date, ngModelOptions.timezone);
332336
}
333337
}
334338

0 commit comments

Comments
 (0)