Reputation: 459
I am using the calendar taken from https://github.com/500tech/angular-simple-calendar.
In this calendar the week starts from sunday and is calculated in this function :
calculateWeeks = function () {
$scope.weeks = [];
var week = null;
var daysInCurrentMonth = new Date($scope.selectedYear, MONTHS.indexOf($scope.selectedMonth) + 1, 0).getDate();
for (var day = 1; day < daysInCurrentMonth + 1; day += 1) {
var dayNumber = new Date($scope.selectedYear, MONTHS.indexOf($scope.selectedMonth), day).getDay();
week = week || [null, null, null, null, null, null, null];
week[dayNumber] = {
year: $scope.selectedYear,
month: MONTHS.indexOf($scope.selectedMonth),
day: day
};
if (allowedDate(week[dayNumber])) {
if ($scope.events) { bindEvent(week[dayNumber]); }
} else {
week[dayNumber].disabled = true;
}
if (dayNumber === 6 || day === daysInCurrentMonth) {
$scope.weeks.push(week);
week = undefined;
}
}
};
What changes I should do to start week from Monday?
Upvotes: 0
Views: 74
Reputation: 350365
You could change the definition of dayNumber
by adding 6 modulo 7:
var dayNumber = (new Date($scope.selectedYear, MONTHS.indexOf($scope.selectedMonth), day)
.getDay() + 6) % 7;
Upvotes: 1