We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 502db82 commit 396ce76Copy full SHA for 396ce76
1 file changed
src/datetime-range.js
@@ -37,7 +37,15 @@ angular.module('g1b.datetime-range', []).
37
// Get number of weeks in month
38
scope.getNumWeeks = function () {
39
if ( !scope.calendar ) { return; }
40
- return Math.floor(scope.calendar.clone().endOf('month').endOf('week').diff(scope.calendar.clone().startOf('month').startOf('week'), 'days') / 7) + 1;
+
41
+ var firstDayOfWeek = scope.calendar.clone().startOf('week').weekday();
42
43
+ var firstOfMonth = scope.calendar.clone().startOf('month');
44
+ var lastOfMonth = scope.calendar.clone().endOf('month');
45
46
+ var firstWeekDay = (firstOfMonth.weekday() - firstDayOfWeek + 7) % 7;
47
48
+ return Math.ceil((firstWeekDay + scope.calendar.daysInMonth()) / 7);
49
}
50
51
// Set selected date
0 commit comments