我使用的是从https://github.com/500tech/angular-simple-calendar获取的日历。
在这个日历中,星期从星期日开始,并在此函数中计算:
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;
}
}
};
从周一开始一周我应该做些什么改变?
答案 0 :(得分:1)
您可以通过添加6模7:
来更改dayNumber
的定义
var dayNumber = (new Date($scope.selectedYear, MONTHS.indexOf($scope.selectedMonth), day)
.getDay() + 6) % 7;