This commit is contained in:
@@ -42,6 +42,9 @@
|
|||||||
<script>
|
<script>
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
export default {
|
export default {
|
||||||
|
beforeCreate() {
|
||||||
|
console.log("Nothing gets called before me!");
|
||||||
|
},
|
||||||
data: () => ({ date: null, modal: false, modal2: false }),
|
data: () => ({ date: null, modal: false, modal2: false }),
|
||||||
props: {
|
props: {
|
||||||
label: String,
|
label: String,
|
||||||
@@ -52,52 +55,56 @@ export default {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
date() {
|
date() {
|
||||||
this.$emit("input", this.date);
|
this.$emit("input", this.date); //always in UTC
|
||||||
},
|
},
|
||||||
value() {
|
value() {
|
||||||
this.date = this.value;
|
this.date = this.value; //always in UTC
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
formatDateTime() {
|
formatDateTime() {
|
||||||
//debugger;
|
|
||||||
return this.value
|
return this.value
|
||||||
? this.$dayjs(this.value).add(this.locale.timeZoneOffset, "hour").format(this.locale.formats.shortDateAndTime)
|
? this.$dayjs(this.value)
|
||||||
|
.add(this.locale.timeZoneOffset, "hour")
|
||||||
|
.format(this.locale.formats.shortDateAndTime)
|
||||||
: "";
|
: "";
|
||||||
},
|
},
|
||||||
formatDate() {
|
formatDate() {
|
||||||
return this.value
|
return this.value
|
||||||
? this.$dayjs(this.value).add(this.locale.timeZoneOffset, "hour").format(this.locale.formats.shortDate)
|
? this.$dayjs(this.value)
|
||||||
|
.add(this.locale.timeZoneOffset, "hour")
|
||||||
|
.format(this.locale.formats.shortDate)
|
||||||
: "";
|
: "";
|
||||||
},
|
},
|
||||||
formatTime() {
|
formatTime() {
|
||||||
//debugger;
|
|
||||||
return this.value
|
return this.value
|
||||||
? this.$dayjs(this.value)
|
? this.$dayjs(this.value)
|
||||||
.add(this.locale.timeZoneOffset, "hour")
|
.add(this.locale.timeZoneOffset, "hour")
|
||||||
.format(this.locale.formats.shortTime)
|
.format(this.locale.formats.shortTime)
|
||||||
: "";
|
: "";
|
||||||
},
|
},
|
||||||
dateOnly: {
|
dateOnly: {
|
||||||
get() {
|
get() {
|
||||||
return this.$dayjs(this.value).add(this.locale.timeZoneOffset, "hour").format("YYYY-MM-DD");
|
return this.$dayjs(this.value)
|
||||||
//return this.value ? this.value.substr(0, 10) : null;
|
.add(this.locale.timeZoneOffset, "hour")
|
||||||
|
.format("YYYY-MM-DD");
|
||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
//this .date is always utc so convert back here before setting or all hell will break loose!
|
this.date = this.$dayjs(value + " " + this.timeOnly)
|
||||||
this.date = this.$dayjs(value + " " + this.timeOnly).subtract(this.locale.timeZoneOffset, "hour").toISOString();
|
.subtract(this.locale.timeZoneOffset, "hour")
|
||||||
//this.date = value + " " + this.timeOnly;
|
.toISOString();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
timeOnly: {
|
timeOnly: {
|
||||||
get() {
|
get() {
|
||||||
return this.$dayjs(this.value).add(this.locale.timeZoneOffset, "hour").format("HH:mm:ss");
|
return this.$dayjs(this.value)
|
||||||
//return this.value ? this.value.substr(11, 8) : null;
|
.add(this.locale.timeZoneOffset, "hour")
|
||||||
|
.format("HH:mm:ss");
|
||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
//debugger;
|
this.date = this.$dayjs(this.dateOnly + " " + value)
|
||||||
//this .date is always utc so convert back here before setting or all hell will break loose!
|
.subtract(this.locale.timeZoneOffset, "hour")
|
||||||
this.date = this.$dayjs(this.dateOnly + " " + value).subtract(this.locale.timeZoneOffset, "hour").toISOString();
|
.toISOString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,6 +112,11 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
|
NOTE: this component was created based on a reddit query and answer below.
|
||||||
|
Note also that the date and time coming in to this component are expected to be an ISO8601 format date and time string in UTC
|
||||||
|
and it's kept in UTC and only localized temporarily for display and selection and update after selection in the date and time picker components
|
||||||
|
|
||||||
re: combined date/time component
|
re: combined date/time component
|
||||||
|
|
||||||
from theRetrograde sent 4 hours ago
|
from theRetrograde sent 4 hours ago
|
||||||
|
|||||||
Reference in New Issue
Block a user