Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed utc as days of weeks are locale specific #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions dist/ng-flat-datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @example <ng-datepicker></ng-datepicker>
*/

ngFlatDatepickerDirective.$inject = ["$templateCache", "$compile", "$document", "datesCalculator"];
angular
.module('ngFlatDatepicker', [])
.directive('ngFlatDatepicker', ngFlatDatepickerDirective);
Expand All @@ -22,7 +23,7 @@

var template = angular.element($templateCache.get('datepicker.html'));
var dateSelected = '';
var today = moment.utc();
var today = moment();

// Default options
var defaultConfig = {
Expand All @@ -34,8 +35,8 @@

// Apply and init options
scope.config = angular.extend(defaultConfig, scope.config);
if (angular.isDefined(scope.config.minDate)) moment.utc(scope.config.minDate).subtract(1, 'day');
if (angular.isDefined(scope.config.maxDate)) moment.utc(scope.config.maxDate).add(1, 'day');
if (angular.isDefined(scope.config.minDate)) moment(scope.config.minDate).subtract(1, 'day');
if (angular.isDefined(scope.config.maxDate)) moment(scope.config.maxDate).add(1, 'day');

// Data
scope.calendarCursor = today;
Expand All @@ -49,7 +50,7 @@

scope.$watch(function(){ return ngModel.$modelValue; }, function(value){
if (value) {
dateSelected = scope.calendarCursor = moment.utc(value, scope.config.dateFormat);
dateSelected = scope.calendarCursor = moment(value, scope.config.dateFormat);
}
});

Expand Down Expand Up @@ -124,7 +125,7 @@
if (!day.isFuture || (scope.config.allowFuture && day.isFuture)) {
resetSelectedDays();
day.isSelected = true;
ngModel.$setViewValue(moment.utc(day.date).format(scope.config.dateFormat));
ngModel.$setViewValue(moment(day.date).format(scope.config.dateFormat));
ngModel.$render();
scope.pickerDisplayed = false;
}
Expand Down Expand Up @@ -153,7 +154,7 @@
function getWeeks (date) {

var weeks = [];
var date = moment.utc(date);
var date = moment(date);
var firstDayOfMonth = moment(date).date(1);
var lastDayOfMonth = moment(date).date(date.daysInMonth());

Expand Down Expand Up @@ -204,7 +205,6 @@
}
};
}
ngFlatDatepickerDirective.$inject = ["$templateCache", "$compile", "$document", "datesCalculator"];

})();

Expand Down
2 changes: 1 addition & 1 deletion dist/ng-flat-datepicker.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/js/datepicker.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var template = angular.element($templateCache.get('datepicker.html'));
var dateSelected = '';
var today = moment.utc();
var today = moment();

// Default options
var defaultConfig = {
Expand All @@ -34,8 +34,8 @@

// Apply and init options
scope.config = angular.extend(defaultConfig, scope.config);
if (angular.isDefined(scope.config.minDate)) moment.utc(scope.config.minDate).subtract(1, 'day');
if (angular.isDefined(scope.config.maxDate)) moment.utc(scope.config.maxDate).add(1, 'day');
if (angular.isDefined(scope.config.minDate)) moment(scope.config.minDate).subtract(1, 'day');
if (angular.isDefined(scope.config.maxDate)) moment(scope.config.maxDate).add(1, 'day');

// Data
scope.calendarCursor = today;
Expand All @@ -49,7 +49,7 @@

scope.$watch(function(){ return ngModel.$modelValue; }, function(value){
if (value) {
dateSelected = scope.calendarCursor = moment.utc(value, scope.config.dateFormat);
dateSelected = scope.calendarCursor = moment(value, scope.config.dateFormat);
}
});

Expand Down Expand Up @@ -124,7 +124,7 @@
if (!day.isFuture || (scope.config.allowFuture && day.isFuture)) {
resetSelectedDays();
day.isSelected = true;
ngModel.$setViewValue(moment.utc(day.date).format(scope.config.dateFormat));
ngModel.$setViewValue(moment(day.date).format(scope.config.dateFormat));
ngModel.$render();
scope.pickerDisplayed = false;
}
Expand Down Expand Up @@ -153,7 +153,7 @@
function getWeeks (date) {

var weeks = [];
var date = moment.utc(date);
var date = moment(date);
var firstDayOfMonth = moment(date).date(1);
var lastDayOfMonth = moment(date).date(date.daysInMonth());

Expand Down