From b9d87afcfcd3ccb627d7414c9b618c310be52e69 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 6 Feb 2020 20:25:05 +0000 Subject: [PATCH] --- ayanova/src/api/locale.js | 27 ++++++++++++++++++ ayanova/src/components/gz-data-table.vue | 6 +++- ayanova/src/main.js | 36 ------------------------ 3 files changed, 32 insertions(+), 37 deletions(-) diff --git a/ayanova/src/api/locale.js b/ayanova/src/api/locale.js index 1040306a..5ec4d75f 100644 --- a/ayanova/src/api/locale.js +++ b/ayanova/src/api/locale.js @@ -255,6 +255,33 @@ export default { timeStyle: "short", hour12: hour12 }); + }, /////////////////////////////////////////// + // Turn a utc date into a displayable + // short date + // + utcDateToShortDateLocalized(value, timeZoneName, languageName) { + if (!value) { + return ""; + } + if (!timeZoneName) { + timeZoneName = this.getTimeZoneName(); + } + if (!languageName) { + languageName = this.getBrowserLanguages(); + } + + //parse the date which is identified as utc ("2020-02-06T18:18:49.148011Z") + var parsedDate = new Date(value); + + //is it a valid date? + if (!(parsedDate instanceof Date && !isNaN(parsedDate))) { + return "not valid"; + } + + return parsedDate.toLocaleDateString(languageName, { + timeZone: timeZoneName, + dateStyle: "short" + }); }, //////////////////////////////////////////////////////// // dynamically set the vuetify language elements from diff --git a/ayanova/src/components/gz-data-table.vue b/ayanova/src/components/gz-data-table.vue index 2f0a93b1..133b4f68 100644 --- a/ayanova/src/components/gz-data-table.vue +++ b/ayanova/src/components/gz-data-table.vue @@ -458,7 +458,11 @@ function buildRecords(listData, columndefinitions, filters) { ); break; case 2: //date only - display = filters.shortdateonlylocalized(display); + display = window.$gz.locale.utcDateToShortDateLocalized( + display, + timeZoneName, + languageName + ); break; case 3: //time only display = filters.shorttimeonlylocalized(display); diff --git a/ayanova/src/main.js b/ayanova/src/main.js index 4ed46e15..9108a6fd 100644 --- a/ayanova/src/main.js +++ b/ayanova/src/main.js @@ -147,43 +147,7 @@ Vue.filter("capitalize", function vueFilterCapitalize(value) { return value.charAt(0).toUpperCase() + value.slice(1); }); -//Convert date to offset value and return as short date time based on browser format -Vue.filter( - "shortdateandtimelocalized", - function vueFilterShortDateAndTimeLocalized(value) { - if (!value) return ""; - //parse the date which is identified as utc ("2020-02-06T18:18:49.148011Z") - var parsedDate = new Date(value); - //parsedDate now contains the correct value - //but any attempt to get it back out that isn't a UTC function will automatically convert to local perceived time zone - - // DATE.toLocaleString('en-GB', { timeZone: 'UTC', dateStyle: "short",timeStyle: "short", hour12: false }) - - var ret = parsedDate.toLocaleString( - window.$gz.locale.getBrowserLanguages(), - { - timeZone: locale.getTimeZoneName(), - dateStyle: "short", - timeStyle: "short", - 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; - } -); //Convert date to localized value and return as short date format chosen Vue.filter("shortdateonlylocalized", function vueFilterShortDateOnlyLocalized(