Skip to content

Commit dd6abc4

Browse files
fix: Make week start on Monday instead of Sunday
1 parent fbcb5ab commit dd6abc4

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/views/activity/daily/ActivityDaily.vue

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,21 @@ export default {
181181
periodReadable: function() {
182182
return moment(this.timeperiod.start).format(this.dateformat);
183183
},
184+
periodLengthMoment: function() {
185+
if (this.periodLength === 'day') {
186+
return 'day';
187+
} else if (this.periodLength === 'week') {
188+
/* This is necessary so the week starts on Monday instead of Sunday */
189+
return 'isoWeek';
190+
} else if (this.periodLength === 'month') {
191+
return 'month';
192+
} else if (this.periodLength === 'year') {
193+
return 'year';
194+
} else {
195+
console.error('Invalid periodLength ${this.periodLength}, defaulting to "day"');
196+
return 'day';
197+
}
198+
},
184199
},
185200
watch: {
186201
timeperiod: function() {
@@ -209,7 +224,7 @@ export default {
209224
},
210225
setDate: function(date, periodLength) {
211226
const new_date = moment(date)
212-
.startOf(periodLength)
227+
.startOf(this.periodLengthMoment)
213228
.format('YYYY-MM-DD');
214229
this.$router.push(`/activity/${this.host}/${periodLength}/${new_date}`);
215230
},

0 commit comments

Comments
 (0)