This commit is contained in:
2019-03-06 17:23:39 +00:00
parent 85bd23ada2
commit ea7637a227
3 changed files with 17 additions and 14 deletions

View File

@@ -47,7 +47,7 @@ export default {
label: String,
value: String,
readonly: { type: Boolean, default: false },
dayjs: Function,
//dayjs: Function,
locale: Object
},
watch: {
@@ -62,42 +62,42 @@ export default {
formatDateTime() {
//debugger;
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() {
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() {
//debugger;
return this.value
? this.dayjs(this.value)
? this.$dayjs(this.value)
.add(this.locale.timeZoneOffset, "hour")
.format(this.locale.formats.shortTime)
: "";
},
dateOnly: {
get() {
return this.dayjs(this.value).add(this.locale.timeZoneOffset, "hour").format("YYYY-MM-DD");
return this.$dayjs(this.value).add(this.locale.timeZoneOffset, "hour").format("YYYY-MM-DD");
//return this.value ? this.value.substr(0, 10) : null;
},
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).subtract(this.locale.timeZoneOffset, "hour").toISOString();
this.date = this.$dayjs(value + " " + this.timeOnly).subtract(this.locale.timeZoneOffset, "hour").toISOString();
//this.date = value + " " + this.timeOnly;
}
},
timeOnly: {
get() {
return this.dayjs(this.value).add(this.locale.timeZoneOffset, "hour").format("HH:mm:ss");
return this.$dayjs(this.value).add(this.locale.timeZoneOffset, "hour").format("HH:mm:ss");
//return this.value ? this.value.substr(11, 8) : null;
},
set(value) {
//debugger;
//this .date is always utc so convert back here before setting or all hell will break loose!
this.date = this.dayjs(this.dateOnly + " " + value).subtract(this.locale.timeZoneOffset, "hour").toISOString();
this.date = this.$dayjs(this.dateOnly + " " + value).subtract(this.locale.timeZoneOffset, "hour").toISOString();
}
}
}

View File

@@ -13,6 +13,12 @@ import "nprogress/nprogress.css";
import dayjs from "dayjs";
import gzdateandtimepicker from "./components/gzdateandtimepicker.vue";
/////////////////////////////////////////////////////////////////
// LIBS
// (https://medium.com/js-dojo/use-any-javascript-library-with-vue-js-3f7e2a4974a8)
//
Object.defineProperty(Vue.prototype, "$dayjs", { value: dayjs });
/////////////////////////////////////////////////////////////////
// FORM VALIDATION
//

View File

@@ -50,11 +50,8 @@
</v-flex>
<v-flex xs12 sm6 lg4 xl3 px-2>
{{ obj.startDate }}
{{ lc.timeZoneOffset }}
<gz-date-time-picker
label="Start"
:dayjs="this.dayjsLib"
label="Start"
:locale="this.lc"
v-model="obj.startDate"
></gz-date-time-picker>
@@ -94,7 +91,7 @@
//import store from "../store";
import locale from "../api/locale";
import api from "../api/apiutil";
import dayjs from "dayjs";
//import dayjs from "dayjs";
//import _ from "../utils/libs/lodash.js";
export default {
components: {},
@@ -102,7 +99,7 @@ export default {
return {
obj: {},
lc: locale,
dayjsLib: dayjs,
// dayjsLib: dayjs,
theDate: new Date(),
date: new Date().toISOString().substr(0, 10),
menu: false,