This commit is contained in:
2019-03-06 00:30:28 +00:00
parent 542dbd53fd
commit 02d8508763
3 changed files with 24 additions and 21 deletions

View File

@@ -41,7 +41,13 @@
</template> <script>
export default {
data: () => ({ date: null, modal: false, modal2: false }),
props: { label: String, value: String, readonly: Boolean },
props: {
label: String,
value: String,
readonly: Boolean,
dayjs: Function,
locale: Object
},
watch: {
date() {
this.$emit("input", this.date);
@@ -52,29 +58,18 @@ export default {
},
computed: {
formatDateTime() {
return this.value.toString();
// let momentObj = this.$moment.utc();
// if (this.value) {
// momentObj = this.$moment.utc(this.value);
// }
// return momentObj.local().format("dddd MM/DD/YYYY h:mm a");
return this.value
? this.dayjs(this.value).format(this.locale.shortDateAndTimeFormat)
: "";
},
formatDate() {
return this.value.toString();
// let momentObj = this.$moment.utc();
// if (this.value) {
// momentObj = this.$moment.utc(this.value);
// }
// return momentObj.local().format("dddd MM/DD/YYYY");
return this.value
? this.dayjs(this.value).format(this.locale.shortTimeFormat)
: "";
},
dateOnly: {
get() {
return this.value ? this.value.substr(0, 10) : null;
// let momentObj = this.$moment.utc();
// if (this.value) {
// momentObj = this.$moment.utc(this.value);
// }
// return momentObj.local().format("YYYY-MM-DD");
},
set(value) {
this.date = value + " " + this.timeOnly;
@@ -94,7 +89,11 @@ export default {
}
},
formatTime() {
return this.value ? this.value.substr(11, 8) : null;
return this.value
? this.dayjs(this.value).format(this.locale.shortTimeFormat)
: "";
//Note in original code this would be parsed expecting source value to be in UTC format coming in but display in local time format
//so
// let momentObj = this.$moment.utc();
// if (this.value) {
// momentObj = this.$moment.utc(this.value);