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 <sukapan1@in.ibm.com>
Change-Id: I581803f230f501c0d34d0b53e7c2d89e8466ee60
diff --git a/src/store/modules/GlobalStore.js b/src/store/modules/GlobalStore.js
index 55b0796..39f3d1d 100644
--- a/src/store/modules/GlobalStore.js
+++ b/src/store/modules/GlobalStore.js
@@ -32,12 +32,16 @@
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 @@
(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 }) {