This commit is contained in:
2020-02-06 19:48:11 +00:00
parent c9f41ee953
commit bb42d34d0c
5 changed files with 34 additions and 13 deletions

View File

@@ -153,12 +153,22 @@ Vue.filter(
function vueFilterShortDateAndTimeLocalized(value) {
if (!value) return "";
var localizedDate = dayjs
.utc(value)
.add(locale.format().timeZoneOffset, "hour")
.toDate();
//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
var tzAdjustedDate = new Date();
tzAdjustedDate.setTime(
parsedDate.getTime() + locale.format().timeZoneOffset * 60 * 60 * 1000
);
return localizedDate.toLocaleString(
// var localizedDate = dayjs
// .utc(value)
// .add(locale.format().timeZoneOffset, "hour")
// .toDate();
var ret = tzAdjustedDate.toLocaleString(
window.$gz.locale.getBrowserLanguages(),
{
dateStyle: "short",
@@ -166,6 +176,19 @@ Vue.filter(
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;
}
);