This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/* eslint-disable */
|
/* xeslint-disable */
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
import roles from "./authorizationroles";
|
import roles from "./authorizationroles";
|
||||||
import locale from "./locale";
|
import locale from "./locale";
|
||||||
@@ -17,14 +17,8 @@ function addNavItem(title, icon, route) {
|
|||||||
// Initialize the app
|
// Initialize the app
|
||||||
// on change of authentication status
|
// on change of authentication status
|
||||||
export default function initialize() {
|
export default function initialize() {
|
||||||
|
|
||||||
console.log("TOP:");
|
|
||||||
console.log(locale);
|
|
||||||
var promise = new Promise(function(resolve) {
|
var promise = new Promise(function(resolve) {
|
||||||
console.log("2:");
|
|
||||||
console.log(locale);
|
|
||||||
if (store.state.authenticated) {
|
if (store.state.authenticated) {
|
||||||
|
|
||||||
//Fetch the core localized text keys that will always be required by user
|
//Fetch the core localized text keys that will always be required by user
|
||||||
locale
|
locale
|
||||||
.fetch(locale.coreKeys)
|
.fetch(locale.coreKeys)
|
||||||
@@ -84,8 +78,6 @@ export default function initialize() {
|
|||||||
// addNavItem(locale.get("Logout"), "sign-out-alt", "/login");
|
// addNavItem(locale.get("Logout"), "sign-out-alt", "/login");
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log("3:");
|
|
||||||
console.log(locale);
|
|
||||||
//CACHE LOCALE SETTINGS
|
//CACHE LOCALE SETTINGS
|
||||||
api
|
api
|
||||||
.get("UserOptions/" + store.state.userId)
|
.get("UserOptions/" + store.state.userId)
|
||||||
@@ -101,10 +93,6 @@ export default function initialize() {
|
|||||||
gzevent.$emit("notify-error", msg);
|
gzevent.$emit("notify-error", msg);
|
||||||
} else {
|
} else {
|
||||||
//TODO: also need the other locale settings such as number and date formats etc
|
//TODO: also need the other locale settings such as number and date formats etc
|
||||||
|
|
||||||
console.log("4:");
|
|
||||||
console.log(locale);
|
|
||||||
|
|
||||||
var localOffset = new Date().getTimezoneOffset();
|
var localOffset = new Date().getTimezoneOffset();
|
||||||
if (localOffset != 0) {
|
if (localOffset != 0) {
|
||||||
localOffset = (localOffset / 60) * -1; //time is in minutes and reversed from what we want or expect
|
localOffset = (localOffset / 60) * -1; //time is in minutes and reversed from what we want or expect
|
||||||
@@ -125,12 +113,8 @@ export default function initialize() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("5:");
|
|
||||||
console.log(locale);
|
|
||||||
//Store offset in locale data
|
//Store offset in locale data
|
||||||
locale.timeZoneOffset = res.data.timeZoneOffset;
|
locale.timeZoneOffset = res.data.timeZoneOffset;
|
||||||
console.log("6 (after change):");
|
|
||||||
console.log(locale);
|
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -99,45 +99,50 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
formatDateTime() {
|
formatDateTime() {
|
||||||
return this.value
|
return this.value
|
||||||
? this.$dayjs(this.value)
|
? this.$dayjs.utc(this.value)
|
||||||
.add(this.$gzlocale.timeZoneOffset, "hour")
|
.add(this.$gzlocale.timeZoneOffset, "hour")
|
||||||
.format(this.$gzlocale.formats.shortDateAndTime)
|
.format(this.$gzlocale.formats.shortDateAndTime)
|
||||||
: "";
|
: "";
|
||||||
},
|
},
|
||||||
formatDate() {
|
formatDate() {
|
||||||
return this.value
|
return this.value
|
||||||
? this.$dayjs(this.value)
|
? this.$dayjs.utc(this.value)
|
||||||
.add(this.$gzlocale.timeZoneOffset, "hour")
|
.add(this.$gzlocale.timeZoneOffset, "hour")
|
||||||
.format(this.$gzlocale.formats.shortDate)
|
.format(this.$gzlocale.formats.shortDate)
|
||||||
: "";
|
: "";
|
||||||
},
|
},
|
||||||
formatTime() {
|
formatTime() {
|
||||||
return this.value
|
return this.value
|
||||||
? this.$dayjs(this.value)
|
? this.$dayjs.utc(this.value)
|
||||||
.add(this.$gzlocale.timeZoneOffset, "hour")
|
.add(this.$gzlocale.timeZoneOffset, "hour")
|
||||||
.format(this.$gzlocale.formats.shortTime)
|
.format(this.$gzlocale.formats.shortTime)
|
||||||
: "";
|
: "";
|
||||||
},
|
},
|
||||||
dateOnly: {
|
dateOnly: {
|
||||||
get() {
|
get() {
|
||||||
return this.$dayjs(this.value)
|
return this.$dayjs.utc(this.value)
|
||||||
.add(this.$gzlocale.timeZoneOffset, "hour")
|
.add(this.$gzlocale.timeZoneOffset, "hour")
|
||||||
.format("YYYY-MM-DD");
|
.format("YYYY-MM-DD");
|
||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
this.date = this.$dayjs(value + " " + this.timeOnly)
|
this.date = this.$dayjs.utc(value + " " + this.timeOnly)
|
||||||
.subtract(this.$gzlocale.timeZoneOffset, "hour")
|
.subtract(this.$gzlocale.timeZoneOffset, "hour")
|
||||||
.toISOString();
|
.toISOString();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
timeOnly: {
|
timeOnly: {
|
||||||
get() {
|
get() {
|
||||||
return this.$dayjs(this.value)
|
return this.$dayjs.utc(this.value)
|
||||||
.add(this.$gzlocale.timeZoneOffset, "hour")
|
.add(this.$gzlocale.timeZoneOffset, "hour")
|
||||||
.format("HH:mm:ss");
|
.format("HH:mm:ss");//BUGBUG: Format here is converting it to local time unexpectedly
|
||||||
|
//this is because of the z in the utc source date and time which triggers format to convert to local time.
|
||||||
|
//for example this will show correctly (note no z at the end) timezoneoffset is -7:
|
||||||
|
//this.$dayjs("2019-05-28T19:01:00").add(this.$gzlocale.timeZoneOffset, "hour").format("HH:mm:ss") == "12:01:00"
|
||||||
|
//whereas this will not
|
||||||
|
//this.$dayjs("2019-05-28T19:01:00").add(this.$gzlocale.timeZoneOffset, "hour").format("HH:mm:ss") == "05:01:00" <-wrong!
|
||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
this.date = this.$dayjs(this.dateOnly + " " + value)
|
this.date = this.$dayjs.utc(this.dateOnly + " " + value)
|
||||||
.subtract(this.$gzlocale.timeZoneOffset, "hour")
|
.subtract(this.$gzlocale.timeZoneOffset, "hour")
|
||||||
.toISOString();
|
.toISOString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import errorHandler from "./api/errorhandler";
|
|||||||
import NProgress from "nprogress";
|
import NProgress from "nprogress";
|
||||||
import "nprogress/nprogress.css";
|
import "nprogress/nprogress.css";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
|
import UTC from "dayjs/plugin/utc"; // load on demand
|
||||||
|
dayjs.extend(UTC); // use plugin
|
||||||
import lodash from "./libs/lodash.min.js";
|
import lodash from "./libs/lodash.min.js";
|
||||||
import VuetifyDialog from "vuetify-dialog";
|
import VuetifyDialog from "vuetify-dialog";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user