This commit is contained in:
@@ -282,6 +282,38 @@ export default {
|
||||
timeZone: timeZoneName,
|
||||
dateStyle: "short"
|
||||
});
|
||||
}, ///////////////////////////////////////////
|
||||
// Turn a utc date into a displayable
|
||||
// short time
|
||||
//
|
||||
utcDateToShortTimeLocalized(value, timeZoneName, languageName, hour12) {
|
||||
if (!value) {
|
||||
return "";
|
||||
}
|
||||
if (!timeZoneName) {
|
||||
timeZoneName = this.getTimeZoneName();
|
||||
}
|
||||
if (!languageName) {
|
||||
languageName = this.getBrowserLanguages();
|
||||
}
|
||||
|
||||
if (!hour12) {
|
||||
hour12 = window.$gz.store.state.locale.hour12;
|
||||
}
|
||||
|
||||
//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.toLocaleTimeString(languageName, {
|
||||
timeZone: timeZoneName,
|
||||
timeStyle: "short",
|
||||
hour12: hour12
|
||||
});
|
||||
},
|
||||
////////////////////////////////////////////////////////
|
||||
// dynamically set the vuetify language elements from
|
||||
|
||||
@@ -450,23 +450,28 @@ function buildRecords(listData, columndefinitions, filters) {
|
||||
var display = column.v;
|
||||
switch (dataType) {
|
||||
case 1: //datetime format to shortdatetime
|
||||
display = window.$gz.locale.utcDateToShortDateAndTimeLocalized(
|
||||
// display = window.$gz.locale.utcDateToShortDateAndTimeLocalized(
|
||||
// display,
|
||||
// timeZoneName,
|
||||
// languageName,
|
||||
// hour12
|
||||
// );
|
||||
// break;
|
||||
// case 2: //date only
|
||||
// display = window.$gz.locale.utcDateToShortDateLocalized(
|
||||
// display,
|
||||
// timeZoneName,
|
||||
// languageName
|
||||
// );
|
||||
// break;
|
||||
case 3: //time only
|
||||
display = display = window.$gz.locale.utcDateToShortTimeLocalized(
|
||||
display,
|
||||
timeZoneName,
|
||||
languageName,
|
||||
hour12
|
||||
);
|
||||
break;
|
||||
case 2: //date only
|
||||
display = window.$gz.locale.utcDateToShortDateLocalized(
|
||||
display,
|
||||
timeZoneName,
|
||||
languageName
|
||||
);
|
||||
break;
|
||||
case 3: //time only
|
||||
display = filters.shorttimeonlylocalized(display);
|
||||
break;
|
||||
// case 6: //bool
|
||||
// display = filters.boolastext(display);
|
||||
// break;
|
||||
|
||||
@@ -149,46 +149,6 @@ Vue.filter("capitalize", function vueFilterCapitalize(value) {
|
||||
|
||||
|
||||
|
||||
//Convert date to localized value and return as short date format chosen
|
||||
Vue.filter("shortdateonlylocalized", function vueFilterShortDateOnlyLocalized(
|
||||
value
|
||||
) {
|
||||
//TODO NOT DONE
|
||||
if (!value) return "";
|
||||
var localizedDate = dayjs
|
||||
.utc(value)
|
||||
.add(locale.format().timeZoneOffset, "hour")
|
||||
.toDate();
|
||||
|
||||
return localizedDate.toLocaleDateString(
|
||||
window.$gz.locale.getBrowserLanguages(),
|
||||
{
|
||||
dateStyle: "short"
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
//Convert date to localized value and return as short date format chosen
|
||||
Vue.filter("shorttimeonlylocalized", function vueFilterShortTimeOnlyLocalized(
|
||||
value
|
||||
) {
|
||||
//TODO NOT DONE
|
||||
if (!value) return "";
|
||||
//new Date().toLocaleString(undefined,{dateStyle:"short",timeStyle:"short",hour12:false})
|
||||
//also toLocaleDateString and toLocaleTimeString well supported use similar options
|
||||
var localizedDate = dayjs
|
||||
.utc(value)
|
||||
.add(locale.format().timeZoneOffset, "hour")
|
||||
.toDate();
|
||||
|
||||
return localizedDate.toLocaleTimeString(
|
||||
window.$gz.locale.getBrowserLanguages(),
|
||||
{
|
||||
timeStyle: "short",
|
||||
hour12: locale.format().hour12
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
//https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString#Browser_compatibility
|
||||
//https://www.currency-iso.org/en/home.html
|
||||
|
||||
Reference in New Issue
Block a user