This commit is contained in:
2020-02-05 23:51:15 +00:00
parent fa56b99f6f
commit ce13b1230b
5 changed files with 43 additions and 21 deletions

View File

@@ -147,14 +147,21 @@ Vue.filter("capitalize", function vueFilterCapitalize(value) {
return value.charAt(0).toUpperCase() + value.slice(1);
});
//Convert date to localized value and return as short date format chosen
Vue.filter("shortdatelocalized", function vueFilterShortDateLocalized(value) {
//Convert date to offset value and return as short date time based on browser format
Vue.filter("shortdatelocalized", function vueFilterShortDateAndTimeLocalized(
value
) {
if (!value) return "";
return dayjs
var localizedDate = dayjs
.utc(value)
.add(locale.format().timeZoneOffset, "hour")
.format(locale.format().shortDateAndTime);
.toDate();
return localizedDate.toLocaleString(undefined, {
dateStyle: "short",
timeStyle: "short",
hour12: locale.format().hour12
});
});
//Convert date to localized value and return as short date format chosen
@@ -176,7 +183,8 @@ Vue.filter("shorttimeonlylocalized", function vueFilterShortTimeOnlyLocalized(
) {
//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
return dayjs
.utc(value)
.add(locale.format().timeZoneOffset, "hour")