diff --git a/src/datepickerPopup/popup.js b/src/datepickerPopup/popup.js index 8e9fd4074d..fb2b62452a 100644 --- a/src/datepickerPopup/popup.js +++ b/src/datepickerPopup/popup.js @@ -32,7 +32,11 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $ this.init = function(_ngModel_) { ngModel = _ngModel_; - ngModelOptions = _ngModel_.$options; + ngModelOptions = angular.isObject(_ngModel_.$options) ? + _ngModel_.$options : + { + timezone: null + }; closeOnDateSelection = angular.isDefined($attrs.closeOnDateSelection) ? $scope.$parent.$eval($attrs.closeOnDateSelection) : datepickerPopupConfig.closeOnDateSelection; @@ -123,13 +127,13 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $ value = new Date(value); } - $scope.date = value; + $scope.date = dateParser.fromTimezone(value, ngModelOptions.timezone); return dateParser.filter($scope.date, dateFormat); }); } else { ngModel.$formatters.push(function(value) { - $scope.date = value; + $scope.date = dateParser.fromTimezone(value, ngModelOptions.timezone); return value; }); } @@ -181,7 +185,7 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $ $scope.isDisabled = function(date) { if (date === 'today') { - date = new Date(); + date = dateParser.fromTimezone(new Date(), ngModelOptions.timezone); } var dates = {}; @@ -328,7 +332,7 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $ if (angular.isString(viewValue)) { var date = parseDateString(viewValue); if (!isNaN(date)) { - return date; + return dateParser.fromTimezone(date, ngModelOptions.timezone); } }