Skip to content

Commit

Permalink
fix: Make week start on Monday instead of Sunday
Browse files Browse the repository at this point in the history
  • Loading branch information
johan-bjareholt committed Apr 18, 2020
1 parent fbcb5ab commit dd6abc4
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/views/activity/daily/ActivityDaily.vue
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,21 @@ export default {
periodReadable: function() {
return moment(this.timeperiod.start).format(this.dateformat);
},
periodLengthMoment: function() {
if (this.periodLength === 'day') {
return 'day';
} else if (this.periodLength === 'week') {
/* This is necessary so the week starts on Monday instead of Sunday */
return 'isoWeek';
} else if (this.periodLength === 'month') {
return 'month';
} else if (this.periodLength === 'year') {
return 'year';
} else {
console.error('Invalid periodLength ${this.periodLength}, defaulting to "day"');
return 'day';
}
},
},
watch: {
timeperiod: function() {
Expand Down Expand Up @@ -209,7 +224,7 @@ export default {
},
setDate: function(date, periodLength) {
const new_date = moment(date)
.startOf(periodLength)
.startOf(this.periodLengthMoment)
.format('YYYY-MM-DD');
this.$router.push(`/activity/${this.host}/${periodLength}/${new_date}`);
},
Expand Down

0 comments on commit dd6abc4

Please sign in to comment.