This commit is contained in:
@@ -217,6 +217,45 @@ export default {
|
|||||||
getTimeZoneName() {
|
getTimeZoneName() {
|
||||||
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||||
},
|
},
|
||||||
|
///////////////////////////////////////////
|
||||||
|
// Turn a utc date into a displayable
|
||||||
|
// short date and time
|
||||||
|
//
|
||||||
|
utcDateToShortDateAndTimeLocalized(
|
||||||
|
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.toLocaleString(languageName, {
|
||||||
|
timeZone: timeZoneName,
|
||||||
|
dateStyle: "short",
|
||||||
|
timeStyle: "short",
|
||||||
|
hour12: locale.format().hour12
|
||||||
|
});
|
||||||
|
},
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
// dynamically set the vuetify language elements from
|
// dynamically set the vuetify language elements from
|
||||||
// users localized text (am/pm etc)
|
// users localized text (am/pm etc)
|
||||||
|
|||||||
Reference in New Issue
Block a user