From fc16f3c268a9d35f889f5770331d11e87ab16af3 Mon Sep 17 00:00:00 2001 From: Sukanya Pandey Date: Tue, 23 Jun 2020 22:54:27 +0530 Subject: Add timezone to profile settings page - Users will have two options to select a timezone. - UTC and browser offset timezone are the two options for the application. - date-fns and date-fns-tz is used for date and time manipulations because:- - The package size of library is smaller. - It allows for importing functions to work with the native date object rather than having to create a moment instance that carries a larger payload. Signed-off-by: Sukanya Pandey Change-Id: I581803f230f501c0d34d0b53e7c2d89e8466ee60 --- src/store/modules/GlobalStore.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/store') diff --git a/src/store/modules/GlobalStore.js b/src/store/modules/GlobalStore.js index 55b07965..39f3d1d4 100644 --- a/src/store/modules/GlobalStore.js +++ b/src/store/modules/GlobalStore.js @@ -32,12 +32,16 @@ const GlobalStore = { bmcTime: null, hostStatus: 'unreachable', languagePreference: localStorage.getItem('storedLanguage') || 'en-US', + isUtcDisplay: localStorage.getItem('storedUtcDisplay') + ? JSON.parse(localStorage.getItem('storedUtcDisplay')) + : true, username: localStorage.getItem('storedUsername') }, getters: { hostStatus: state => state.hostStatus, bmcTime: state => state.bmcTime, languagePreference: state => state.languagePreference, + isUtcDisplay: state => state.isUtcDisplay, username: state => state.username }, mutations: { @@ -46,7 +50,8 @@ const GlobalStore = { (state.hostStatus = hostStateMapper(hostState)), setLanguagePreference: (state, language) => (state.languagePreference = language), - setUsername: (state, username) => (state.username = username) + setUsername: (state, username) => (state.username = username), + setUtcTime: (state, isUtcDisplay) => (state.isUtcDisplay = isUtcDisplay) }, actions: { async getBmcTime({ commit }) { -- cgit v1.2.3