A very very useful widget but maybe a timezone setting is missing.
(function (angular) {
var momentPickerProvider = (function () {
function momentPickerProvider() {
defaults = {
...
/*** PATCH START ***/
timezone: undefined, // e.g. +0100
/*** PATCH END ***/
...
};
};
...
})();
var MomentPickerDirective = (function () {
function MomentPickerDirective(timeout, sce, compile, document, momentPickerProvider) {
this.restrict = 'A',
this.scope = {
...
/*** PATCH START ***/
timezone: '@?',
/*** PATCH END ***/
...
};
...
};
MomentPickerDirective.prototype.$inject = ['$timeout', '$sce', '$compile', '$document', 'momentPicker'];
MomentPickerDirective.prototype.link = function ($scope, $element, $attrs) {
/*** PATCH START ***/
function momentTZ(input, format, locale) {
var tz = $scope.timezone;
if (angular.isDefined(input)) {
if (!angular.isDefined(tz)) return moment(input, format, locale);
return moment(input + ' ' + tz, format + ' Z', locale).utcOffset(tz);
}
return (angular.isDefined(tz) ? moment().utcOffset(tz) : moment());
}
/*** PATCH END ***/
$scope.template = (
...
);
// one-way binding attributes
...
// utilities
...
$scope.limits = {
...
checkView: function () {
/*** PATCH START ***/
if (!angular.isDefined($scope.view.moment)) $scope.view.moment = momentTZ().locale($scope.locale);
/*** PATCH END ***/
...
}
};
...
// month view
$scope.monthView = {
days: (function () {
var days = [],
/*** PATCH START ***/
day = momentTZ().locale($scope.locale).startOf('week');
/*** PATCH END ***/
...
})(),
...
};
...
// creation
...
// initialization
...
// properties listeners
$scope.$watch('model', function (model, previous) {
if (angular.isDefined(model)) {
/*** PATCH START ***/
$scope.valueMoment = momentTZ(model, $scope.format, $scope.locale);
/*** PATCH END ***/
...
}
...
});
...
$scope.$watch('[minDate, maxDate]', function () {
angular.forEach(['minDate', 'maxDate'], function (limitValue) {
if (angular.isDefined($scope[limitValue])) {
/*** PATCH START ***/
$scope[limitValue + 'Moment'] = momentTZ($scope[limitValue], $scope.format, $scope.locale);
/*** PATCH END ***/
...
}
});
...
}, true);
...
};
return MomentPickerDirective;
})();
...
})(window.angular);