File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff 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 },
You can’t perform that action at this time.
0 commit comments