Skip to content

Commit b248579

Browse files
author
Nathan Reyes
committed
Fix miscalculation of day numbers for previous months when . Closes #44.
1 parent f692372 commit b248579

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# v0.5.5
2+
## Bug Fixes
3+
* Fix miscalculation of day numbers for previous months when `firstDayOfWeek !== 1`. Closes #44.
4+
15
# v0.5.4
26
## Bug Fixes
37
* Pass missing `page` attribute to `header-title` slot

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "v-calendar",
3-
"version": "0.5.4",
3+
"version": "0.5.5",
44
"description": "A clean and extendable plugin for building simple attributed calendars in Vue.js.",
55
"keywords": [
66
"vue",

src/components/CalendarWeeks.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ export default {
3939
weeks() {
4040
const weeks = [];
4141
const { firstDayOfWeek, firstWeekday } = this.monthComps;
42+
const prevMonthDaysToShow = (firstWeekday + (firstWeekday < firstDayOfWeek ? 7 : 0)) - firstDayOfWeek;
4243
let prevMonth = true;
4344
let thisMonth = false;
4445
let nextMonth = false;
4546
// Init counters with previous month's data
46-
let day = (this.prevMonthComps.days - Math.abs(firstWeekday - firstDayOfWeek)) + 1;
47+
let day = (this.prevMonthComps.days - prevMonthDaysToShow) + 1;
4748
let dayFromEnd = (this.prevMonthComps.days - day) + 1;
4849
let weekdayOrdinal = Math.floor(((day - 1) / 7) + 1);
4950
let weekdayOrdinalFromEnd = 1;

0 commit comments

Comments
 (0)