This commit is contained in:
2020-02-06 20:25:05 +00:00
parent c3ead923d9
commit b9d87afcfc
3 changed files with 32 additions and 37 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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(