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

@@ -45,7 +45,7 @@ export default {
beforeCreate() {
//created() {
//check pre-requisites exist just in case
if (!this.$dayjs) {
if (!this.$dayjs) {
throw "GzDateAndTimePicker: the DayJS library is required and missing";
}
},
@@ -53,9 +53,7 @@ export default {
props: {
label: String,
value: String,
readonly: { type: Boolean, default: false },
//dayjs: Function,
locale: Object
readonly: { type: Boolean, default: false }
},
watch: {
date() {
@@ -69,45 +67,45 @@ export default {
formatDateTime() {
return this.value
? this.$dayjs(this.value)
.add(this.locale.timeZoneOffset, "hour")
.format(this.locale.formats.shortDateAndTime)
.add(this.$gzlocale.timeZoneOffset, "hour")
.format(this.$gzlocale.formats.shortDateAndTime)
: "";
},
formatDate() {
return this.value
? this.$dayjs(this.value)
.add(this.locale.timeZoneOffset, "hour")
.format(this.locale.formats.shortDate)
.add(this.$gzlocale.timeZoneOffset, "hour")
.format(this.$gzlocale.formats.shortDate)
: "";
},
formatTime() {
return this.value
? this.$dayjs(this.value)
.add(this.locale.timeZoneOffset, "hour")
.format(this.locale.formats.shortTime)
.add(this.$gzlocale.timeZoneOffset, "hour")
.format(this.$gzlocale.formats.shortTime)
: "";
},
dateOnly: {
get() {
return this.$dayjs(this.value)
.add(this.locale.timeZoneOffset, "hour")
.add(this.$gzlocale.timeZoneOffset, "hour")
.format("YYYY-MM-DD");
},
set(value) {
this.date = this.$dayjs(value + " " + this.timeOnly)
.subtract(this.locale.timeZoneOffset, "hour")
.subtract(this.$gzlocale.timeZoneOffset, "hour")
.toISOString();
}
},
timeOnly: {
get() {
return this.$dayjs(this.value)
.add(this.locale.timeZoneOffset, "hour")
.add(this.$gzlocale.timeZoneOffset, "hour")
.format("HH:mm:ss");
},
set(value) {
this.date = this.$dayjs(this.dateOnly + " " + value)
.subtract(this.locale.timeZoneOffset, "hour")
.subtract(this.$gzlocale.timeZoneOffset, "hour")
.toISOString();
}
}

View File

@@ -50,7 +50,7 @@
</v-flex>
<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 xs12 sm6 lg4 xl3 px-2>