This commit is contained in:
2020-02-06 19:48:11 +00:00
parent c9f41ee953
commit bb42d34d0c
5 changed files with 34 additions and 13 deletions

View File

@@ -76,6 +76,8 @@ TODO: LOCALIZATION
- already something in there for currency I think - already something in there for currency I think
- PLANNING - PLANNING
- Proper way to definitevely display a date in desired time zone: DATE.toLocaleString('en-GB', { timeZone: 'UTC', dateStyle: "short",timeStyle: "short", hour12: false })
- NEED to accept and display numbers and dates and times, nothing else really matters - NEED to accept and display numbers and dates and times, nothing else really matters
- NUMBER FORMATTING REQUIRED INFO - NUMBER FORMATTING REQUIRED INFO
- USEROPTIONS: Currency symbol - USEROPTIONS: Currency symbol

View File

@@ -57,7 +57,7 @@ export default {
date: null, date: null,
oldDate: null, oldDate: null,
dlgdate: false, dlgdate: false,
defaultLocale: window.$gz.locale.getFirstBrowserLanguage().split("-", 1)[0] defaultLocale: window.$gz.locale.getBrowserFirstLanguage().split("-", 1)[0]
}), }),
props: { props: {
label: String, label: String,

View File

@@ -94,17 +94,13 @@ export default {
throw "DateTimeControl: $gz.locale is required and missing"; throw "DateTimeControl: $gz.locale is required and missing";
} }
} }
// this.defaultLocale = window.$gz.locale
// .getFirstBrowserLanguage()
// .split("-", 1);
}, },
data: () => ({ data: () => ({
date: null, date: null,
oldDate: null, oldDate: null,
dlgdate: false, dlgdate: false,
dlgtime: false, dlgtime: false,
defaultLocale: window.$gz.locale.getFirstBrowserLanguage().split("-", 1)[0], defaultLocale: window.$gz.locale.getBrowserFirstLanguage().split("-", 1)[0],
ampmFormat: window.$gz.locale.format().hour12 ? "ampm" : "24hr" ampmFormat: window.$gz.locale.format().hour12 ? "ampm" : "24hr"
}), }),
props: { props: {

View File

@@ -153,12 +153,22 @@ Vue.filter(
function vueFilterShortDateAndTimeLocalized(value) { function vueFilterShortDateAndTimeLocalized(value) {
if (!value) return ""; if (!value) return "";
var localizedDate = dayjs //parse the date which is identified as utc ("2020-02-06T18:18:49.148011Z")
.utc(value) var parsedDate = new Date(value);
.add(locale.format().timeZoneOffset, "hour") //parsedDate now contains the correct value
.toDate(); //but any attempt to get it back out that isn't a UTC function will automatically convert to local perceived time zone
var tzAdjustedDate = new Date();
tzAdjustedDate.setTime(
parsedDate.getTime() + locale.format().timeZoneOffset * 60 * 60 * 1000
);
return localizedDate.toLocaleString( // var localizedDate = dayjs
// .utc(value)
// .add(locale.format().timeZoneOffset, "hour")
// .toDate();
var ret = tzAdjustedDate.toLocaleString(
window.$gz.locale.getBrowserLanguages(), window.$gz.locale.getBrowserLanguages(),
{ {
dateStyle: "short", dateStyle: "short",
@@ -166,6 +176,19 @@ Vue.filter(
hour12: locale.format().hour12 hour12: locale.format().hour12
} }
); );
console.log("value");
console.log(value);
console.log("parsedDate");
console.log(parsedDate);
console.log("tzAdjustedDate");
console.log(tzAdjustedDate);
console.log("presented as:");
console.log(ret);
console.log("-------");
//debugger;
return ret;
} }
); );

View File

@@ -1,6 +1,6 @@
<template> <template>
<div> <div>
User's preferred language: User's preferred languages:
{{ userLanguage }} {{ userLanguage }}
</div> </div>
</template> </template>
@@ -11,7 +11,7 @@ import UnderConstruction from "../components/underconstruction.vue";
export default { export default {
data() { data() {
return { return {
userLanguage: window.$gz.locale.getFirstBrowserLanguage() userLanguage: window.$gz.locale.getBrowserLanguages()
}; };
}, },
components: {}, components: {},