This commit is contained in:
2019-05-28 23:15:31 +00:00
parent 1f7cd6b692
commit cddbf99177
3 changed files with 16 additions and 25 deletions

View File

@@ -99,45 +99,50 @@ export default {
computed: {
formatDateTime() {
return this.value
? this.$dayjs(this.value)
? this.$dayjs.utc(this.value)
.add(this.$gzlocale.timeZoneOffset, "hour")
.format(this.$gzlocale.formats.shortDateAndTime)
: "";
},
formatDate() {
return this.value
? this.$dayjs(this.value)
? this.$dayjs.utc(this.value)
.add(this.$gzlocale.timeZoneOffset, "hour")
.format(this.$gzlocale.formats.shortDate)
: "";
},
formatTime() {
return this.value
? this.$dayjs(this.value)
? this.$dayjs.utc(this.value)
.add(this.$gzlocale.timeZoneOffset, "hour")
.format(this.$gzlocale.formats.shortTime)
: "";
},
dateOnly: {
get() {
return this.$dayjs(this.value)
return this.$dayjs.utc(this.value)
.add(this.$gzlocale.timeZoneOffset, "hour")
.format("YYYY-MM-DD");
},
set(value) {
this.date = this.$dayjs(value + " " + this.timeOnly)
this.date = this.$dayjs.utc(value + " " + this.timeOnly)
.subtract(this.$gzlocale.timeZoneOffset, "hour")
.toISOString();
}
},
timeOnly: {
get() {
return this.$dayjs(this.value)
return this.$dayjs.utc(this.value)
.add(this.$gzlocale.timeZoneOffset, "hour")
.format("HH:mm:ss");
.format("HH:mm:ss");//BUGBUG: Format here is converting it to local time unexpectedly
//this is because of the z in the utc source date and time which triggers format to convert to local time.
//for example this will show correctly (note no z at the end) timezoneoffset is -7:
//this.$dayjs("2019-05-28T19:01:00").add(this.$gzlocale.timeZoneOffset, "hour").format("HH:mm:ss") == "12:01:00"
//whereas this will not
//this.$dayjs("2019-05-28T19:01:00").add(this.$gzlocale.timeZoneOffset, "hour").format("HH:mm:ss") == "05:01:00" <-wrong!
},
set(value) {
this.date = this.$dayjs(this.dateOnly + " " + value)
this.date = this.$dayjs.utc(this.dateOnly + " " + value)
.subtract(this.$gzlocale.timeZoneOffset, "hour")
.toISOString();
}