@@ -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