This commit is contained in:
2019-03-06 20:53:15 +00:00
parent 8d30093935
commit a6706864bf
2 changed files with 13 additions and 15 deletions

View File

@@ -53,9 +53,7 @@ export default {
props: { props: {
label: String, label: String,
value: String, value: String,
readonly: { type: Boolean, default: false }, readonly: { type: Boolean, default: false }
//dayjs: Function,
locale: Object
}, },
watch: { watch: {
date() { date() {
@@ -69,45 +67,45 @@ export default {
formatDateTime() { formatDateTime() {
return this.value return this.value
? this.$dayjs(this.value) ? this.$dayjs(this.value)
.add(this.locale.timeZoneOffset, "hour") .add(this.$gzlocale.timeZoneOffset, "hour")
.format(this.locale.formats.shortDateAndTime) .format(this.$gzlocale.formats.shortDateAndTime)
: ""; : "";
}, },
formatDate() { formatDate() {
return this.value return this.value
? this.$dayjs(this.value) ? this.$dayjs(this.value)
.add(this.locale.timeZoneOffset, "hour") .add(this.$gzlocale.timeZoneOffset, "hour")
.format(this.locale.formats.shortDate) .format(this.$gzlocale.formats.shortDate)
: ""; : "";
}, },
formatTime() { formatTime() {
return this.value return this.value
? this.$dayjs(this.value) ? this.$dayjs(this.value)
.add(this.locale.timeZoneOffset, "hour") .add(this.$gzlocale.timeZoneOffset, "hour")
.format(this.locale.formats.shortTime) .format(this.$gzlocale.formats.shortTime)
: ""; : "";
}, },
dateOnly: { dateOnly: {
get() { get() {
return this.$dayjs(this.value) return this.$dayjs(this.value)
.add(this.locale.timeZoneOffset, "hour") .add(this.$gzlocale.timeZoneOffset, "hour")
.format("YYYY-MM-DD"); .format("YYYY-MM-DD");
}, },
set(value) { set(value) {
this.date = this.$dayjs(value + " " + this.timeOnly) this.date = this.$dayjs(value + " " + this.timeOnly)
.subtract(this.locale.timeZoneOffset, "hour") .subtract(this.$gzlocale.timeZoneOffset, "hour")
.toISOString(); .toISOString();
} }
}, },
timeOnly: { timeOnly: {
get() { get() {
return this.$dayjs(this.value) return this.$dayjs(this.value)
.add(this.locale.timeZoneOffset, "hour") .add(this.$gzlocale.timeZoneOffset, "hour")
.format("HH:mm:ss"); .format("HH:mm:ss");
}, },
set(value) { set(value) {
this.date = this.$dayjs(this.dateOnly + " " + value) this.date = this.$dayjs(this.dateOnly + " " + value)
.subtract(this.locale.timeZoneOffset, "hour") .subtract(this.$gzlocale.timeZoneOffset, "hour")
.toISOString(); .toISOString();
} }
} }

View File

@@ -50,7 +50,7 @@
</v-flex> </v-flex>
<v-flex xs12 sm6 lg4 xl3 px-2> <v-flex xs12 sm6 lg4 xl3 px-2>
<gz-date-time-picker label="Start" :locale="this.$gzlocale" v-model="obj.startDate"></gz-date-time-picker> <gz-date-time-picker label="Start" v-model="obj.startDate"></gz-date-time-picker>
</v-flex> </v-flex>
<v-flex xs12 sm6 lg4 xl3 px-2> <v-flex xs12 sm6 lg4 xl3 px-2>