This commit is contained in:
2020-02-06 00:55:04 +00:00
parent 4e51b26258
commit 38ec953b25
4 changed files with 46 additions and 25 deletions

View File

@@ -55,6 +55,7 @@
ref="theTimePicker" ref="theTimePicker"
scrollable scrollable
ampm-in-title ampm-in-title
:format="ampmFormat"
v-model="timeOnly" v-model="timeOnly"
> >
<v-spacer></v-spacer> <v-spacer></v-spacer>
@@ -103,7 +104,8 @@ export default {
oldDate: null, oldDate: null,
dlgdate: false, dlgdate: false,
dlgtime: false, dlgtime: false,
defaultLocale: window.$gz.locale.getFirstBrowserLanguage().split("-", 1)[0] defaultLocale: window.$gz.locale.getFirstBrowserLanguage().split("-", 1)[0],
ampmFormat: window.$gz.locale.format().hour12 ? "ampm" : "24hr"
}), }),
props: { props: {
label: String, label: String,

View File

@@ -445,7 +445,7 @@ function buildRecords(listData, columndefinitions, filters) {
var display = column.v; var display = column.v;
switch (dataType) { switch (dataType) {
case 1: //datetime format to shortdatetime case 1: //datetime format to shortdatetime
display = filters.shortdatelocalized(display); display = filters.shortdateandtimelocalized(display);
break; break;
case 2: //date only case 2: //date only
display = filters.shortdateonlylocalized(display); display = filters.shortdateonlylocalized(display);

View File

@@ -148,21 +148,26 @@ Vue.filter("capitalize", function vueFilterCapitalize(value) {
}); });
//Convert date to offset value and return as short date time based on browser format //Convert date to offset value and return as short date time based on browser format
Vue.filter("shortdatelocalized", function vueFilterShortDateAndTimeLocalized( Vue.filter(
value "shortdateandtimelocalized",
) { function vueFilterShortDateAndTimeLocalized(value) {
if (!value) return ""; if (!value) return "";
var localizedDate = dayjs var localizedDate = dayjs
.utc(value) .utc(value)
.add(locale.format().timeZoneOffset, "hour") .add(locale.format().timeZoneOffset, "hour")
.toDate(); .toDate();
return localizedDate.toLocaleString(undefined, {
dateStyle: "short", return localizedDate.toLocaleString(
timeStyle: "short", window.$gz.locale.getFirstBrowserLanguage(),
hour12: locale.format().hour12 {
}); dateStyle: "short",
}); timeStyle: "short",
hour12: locale.format().hour12
}
);
}
);
//Convert date to localized value and return as short date format chosen //Convert date to localized value and return as short date format chosen
Vue.filter("shortdateonlylocalized", function vueFilterShortDateOnlyLocalized( Vue.filter("shortdateonlylocalized", function vueFilterShortDateOnlyLocalized(
@@ -170,11 +175,17 @@ Vue.filter("shortdateonlylocalized", function vueFilterShortDateOnlyLocalized(
) { ) {
//TODO NOT DONE //TODO NOT DONE
if (!value) return ""; if (!value) return "";
var localizedDate = dayjs
return dayjs
.utc(value) .utc(value)
.add(locale.format().timeZoneOffset, "hour") .add(locale.format().timeZoneOffset, "hour")
.format(locale.format().shortDateAndTime); .toDate();
return localizedDate.toLocaleDateString(
window.$gz.locale.getFirstBrowserLanguage(),
{
dateStyle: "short"
}
);
}); });
//Convert date to localized value and return as short date format chosen //Convert date to localized value and return as short date format chosen
@@ -185,10 +196,18 @@ Vue.filter("shorttimeonlylocalized", function vueFilterShortTimeOnlyLocalized(
if (!value) return ""; if (!value) return "";
//new Date().toLocaleString(undefined,{dateStyle:"short",timeStyle:"short",hour12:false}) //new Date().toLocaleString(undefined,{dateStyle:"short",timeStyle:"short",hour12:false})
//also toLocaleDateString and toLocaleTimeString well supported use similar options //also toLocaleDateString and toLocaleTimeString well supported use similar options
return dayjs var localizedDate = dayjs
.utc(value) .utc(value)
.add(locale.format().timeZoneOffset, "hour") .add(locale.format().timeZoneOffset, "hour")
.format(locale.format().shortDateAndTime); .toDate();
return localizedDate.toLocaleTimeString(
window.$gz.locale.getFirstBrowserLanguage(),
{
timeStyle: "short",
hour12: locale.format().hour12
}
);
}); });
Vue.filter("currency", function vueFilterCurrency(value) { Vue.filter("currency", function vueFilterCurrency(value) {

View File

@@ -25,9 +25,9 @@
</div> </div>
<div> <div>
<span class="ml-6 body-1">{{ lt("Language") }}:</span> <span class="ml-6 body-1">12h:</span>
<span class="body-2"> <span class="body-2">
{{ ltFormat().tag }} {{ ltFormat().hour12 }}
</span> </span>
</div> </div>
@@ -48,7 +48,7 @@
<span class="body-2">{{ ltFormat().currencySymbol }}</span> <span class="body-2">{{ ltFormat().currencySymbol }}</span>
</div> </div>
<div> <!-- <div>
<span class="ml-6 body-1">{{ lt("ShortDateFormat") }}:</span> <span class="ml-6 body-1">{{ lt("ShortDateFormat") }}:</span>
<span class="body-2">{{ ltFormat().shortDate }}</span> <span class="body-2">{{ ltFormat().shortDate }}</span>
</div> </div>
@@ -61,7 +61,7 @@
<div> <div>
<span class="ml-6 body-1">{{ lt("ShortDateAndTimeFormat") }}: </span> <span class="ml-6 body-1">{{ lt("ShortDateAndTimeFormat") }}: </span>
<span class="body-2">{{ ltFormat().shortDateAndTime }}</span> <span class="body-2">{{ ltFormat().shortDateAndTime }}</span>
</div> </div> -->
<v-divider class="mt-6"></v-divider> <v-divider class="mt-6"></v-divider>
<v-subheader>{{ lt("Browser") }}</v-subheader> <v-subheader>{{ lt("Browser") }}</v-subheader>