File tree Expand file tree Collapse file tree 3 files changed +13
-12
lines changed
Expand file tree Collapse file tree 3 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ import 'vue-awesome/icons/arrow-left';
8787import ' vue-awesome/icons/arrow-right' ;
8888import { mapState } from ' pinia' ;
8989import { useSettingsStore } from ' ~/stores/settings' ;
90+ import { get_first_day_of_week } from ' ~/util/time' ;
9091
9192export default {
9293 name: ' input-timeinterval' ,
@@ -153,12 +154,7 @@ export default {
153154 return moment (this .start ).add (this .maxDuration , ' seconds' ).isBefore (moment (this .end ));
154155 },
155156 firstDayOfWeek() {
156- const mapping = {
157- Sunday: 0 ,
158- Monday: 1 ,
159- Saturday: 6 ,
160- };
161- return mapping [this .startOfWeek ] !== undefined ? mapping [this .startOfWeek ] : 1 ;
157+ return get_first_day_of_week (this .startOfWeek );
162158 },
163159 },
164160 mounted() {
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import moment from 'moment';
1919import { mapState } from ' pinia' ;
2020import { useBucketsStore } from ' ~/stores/buckets' ;
2121import { useSettingsStore } from ' ~/stores/settings' ;
22+ import { get_first_day_of_week } from ' ~/util/time' ;
2223
2324export default Vue .extend ({
2425 name: ' QueryOptions' ,
@@ -46,12 +47,7 @@ export default Vue.extend({
4647 return this .bucketsStore .hosts ;
4748 },
4849 firstDayOfWeek() {
49- const mapping = {
50- Sunday: 0 ,
51- Monday: 1 ,
52- Saturday: 6 ,
53- };
54- return mapping [this .startOfWeek ] !== undefined ? mapping [this .startOfWeek ] : 1 ;
50+ return get_first_day_of_week (this .startOfWeek );
5551 },
5652 },
5753
Original file line number Diff line number Diff line change @@ -94,3 +94,12 @@ export function get_today_with_offset(offset?: string): string {
9494 const offset_dur = get_offset_duration ( offset ) ;
9595 return moment ( ) . subtract ( offset_dur ) . startOf ( 'day' ) . format ( 'YYYY-MM-DD' ) ;
9696}
97+
98+ export function get_first_day_of_week ( startOfWeek : string ) : number {
99+ const mapping : Record < string , number > = {
100+ Sunday : 0 ,
101+ Monday : 1 ,
102+ Saturday : 6 ,
103+ } ;
104+ return mapping [ startOfWeek ] !== undefined ? mapping [ startOfWeek ] : 1 ;
105+ }
You can’t perform that action at this time.
0 commit comments