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

@@ -72,6 +72,9 @@ export default {
},
formats: {
decimalSeparator: ".",
currencySymbol: "$"
currencySymbol: "$",
shortDateFormat: "YYYY-MM-DD",
shortTimeFormat: "hh:mm:ss A",
shortDateAndTimeFormat: "YYYY-MM-DD hh:mm:ss A"
}
};

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);

View File

@@ -50,7 +50,7 @@
</v-flex>
<v-flex xs12 sm6 lg4 xl3 px-2>
<gz-date-time-picker label="Start" v-model="obj.startDate"></gz-date-time-picker>
<gz-date-time-picker label="Start" :dayjs="this.dayjsLib" :locale="this.lc" v-model="obj.startDate"></gz-date-time-picker>
</v-flex>
<v-flex xs12 sm6 lg4 xl3 px-2>
@@ -95,6 +95,7 @@ export default {
return {
obj: {},
lc: locale,
dayjsLib: dayjs,
theDate: new Date(),
date: new Date().toISOString().substr(0, 10),
menu: false,