This commit is contained in:
@@ -40,23 +40,13 @@
|
|||||||
/* Xeslint-disable */
|
/* Xeslint-disable */
|
||||||
//******************************** NOTE: this control also captures the TIME even though it's DATE only, this is an intentional design decision to support field change to date or date AND time and is considered a display issue */
|
//******************************** NOTE: this control also captures the TIME even though it's DATE only, this is an intentional design decision to support field change to date or date AND time and is considered a display issue */
|
||||||
export default {
|
export default {
|
||||||
beforeCreate() {
|
|
||||||
//debugger;@input="dlgdate = false"
|
|
||||||
//this is a nothing line as a test
|
|
||||||
//check pre-requisites exist just in case
|
|
||||||
if (window.$gz.errorHandler.devMode()) {
|
|
||||||
if (!window.$gz.dayjs) {
|
|
||||||
throw "DateTimeControl: the DayJS library is required and missing";
|
|
||||||
}
|
|
||||||
if (!window.$gz.locale) {
|
|
||||||
throw "DateTimeControl: $gz.locale is required and missing";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data: () => ({
|
data: () => ({
|
||||||
date: null,
|
date: null,
|
||||||
oldDate: null,
|
oldDate: null,
|
||||||
dlgdate: false,
|
dlgdate: false,
|
||||||
|
//cache display format stuff
|
||||||
|
timeZoneName: window.$gz.locale.getTimeZoneName(),
|
||||||
|
languageName: window.$gz.locale.getBrowserLanguages(),
|
||||||
defaultLocale: window.$gz.locale.getBrowserFirstLanguage().split("-", 1)[0]
|
defaultLocale: window.$gz.locale.getBrowserFirstLanguage().split("-", 1)[0]
|
||||||
}),
|
}),
|
||||||
props: {
|
props: {
|
||||||
@@ -96,72 +86,57 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
formatDateTime() {
|
formatDateTime() {
|
||||||
return this.value
|
return window.$gz.locale.utcDateToShortDateAndTimeLocalized(
|
||||||
? window.$gz.dayjs
|
this.value,
|
||||||
.utc(this.value)
|
this.timeZoneName,
|
||||||
.add(window.$gz.locale.format().timeZoneOffset, "hour")
|
this.languageName,
|
||||||
.format(window.$gz.locale.format().shortDateAndTime)
|
this.hour12
|
||||||
: "";
|
);
|
||||||
},
|
},
|
||||||
formatDate() {
|
formatDate() {
|
||||||
return this.value
|
return window.$gz.locale.utcDateToShortDateLocalized(
|
||||||
? window.$gz.dayjs
|
this.value,
|
||||||
.utc(this.value)
|
this.timeZoneName,
|
||||||
.add(window.$gz.locale.format().timeZoneOffset, "hour")
|
this.languageName
|
||||||
.format(window.$gz.locale.format().shortDate)
|
);
|
||||||
: "";
|
|
||||||
},
|
},
|
||||||
formatTime() {
|
formatTime() {
|
||||||
return this.value
|
return window.$gz.locale.utcDateToShortTimeLocalized(
|
||||||
? window.$gz.dayjs
|
this.value,
|
||||||
.utc(this.value)
|
this.timeZoneName,
|
||||||
.add(window.$gz.locale.format().timeZoneOffset, "hour")
|
this.languageName,
|
||||||
.format(window.$gz.locale.format().shortTime)
|
this.hour12
|
||||||
: "";
|
);
|
||||||
},
|
},
|
||||||
dateOnly: {
|
dateOnly: {
|
||||||
get() {
|
get() {
|
||||||
//TODO: this will likely need an improvement for forms where there should be an automatic pre-set time chosen like workorder labor;
|
//return date only portion converted to local working time zone: YYYY-MM-DD
|
||||||
var defaultDateString = window.$gz
|
return window.$gz.locale.utcDateStringToLocal8601DateOnlyString(
|
||||||
.dayjs()
|
this.value,
|
||||||
.utc()
|
this.timeZoneName
|
||||||
.add(window.$gz.locale.format().timeZoneOffset, "hour")
|
);
|
||||||
.format("YYYY-MM-DD");
|
|
||||||
|
|
||||||
return this.value
|
|
||||||
? window.$gz.dayjs
|
|
||||||
.utc(this.value)
|
|
||||||
.add(window.$gz.locale.format().timeZoneOffset, "hour")
|
|
||||||
.format("YYYY-MM-DD")
|
|
||||||
: defaultDateString;
|
|
||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
this.date = window.$gz.dayjs
|
this.date = window.$gz.locale.localTimeDateStringToUTC8601String(
|
||||||
.utc(value + " " + this.timeOnly)
|
value + "T" + this.timeOnly,
|
||||||
.subtract(window.$gz.locale.format().timeZoneOffset, "hour")
|
this.timeZoneName
|
||||||
.toISOString();
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
timeOnly: {
|
timeOnly: {
|
||||||
|
//expects just the hours minutes seconds portion: 18:18:49
|
||||||
|
//Needs to convert into and out of the desired time zone or the control will show the UTC time instead
|
||||||
get() {
|
get() {
|
||||||
//TODO: this will likely need an improvement for forms where there should be an automatic pre-set time chosen like workorder labor;
|
return window.$gz.locale.utcDateStringToLocal8601TimeOnlyString(
|
||||||
var defaultTimeString = window.$gz.dayjs
|
this.value,
|
||||||
.utc()
|
this.timeZoneName
|
||||||
.add(window.$gz.locale.format().timeZoneOffset, "hour")
|
);
|
||||||
.format("HH:mm:ss");
|
|
||||||
|
|
||||||
return this.value
|
|
||||||
? window.$gz.dayjs
|
|
||||||
.utc(this.value)
|
|
||||||
.add(window.$gz.locale.format().timeZoneOffset, "hour")
|
|
||||||
.format("HH:mm:ss")
|
|
||||||
: defaultTimeString;
|
|
||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
this.date = window.$gz.dayjs
|
this.date = window.$gz.locale.localTimeDateStringToUTC8601String(
|
||||||
.utc(this.dateOnly + " " + value)
|
this.dateOnly + "T" + value,
|
||||||
.subtract(window.$gz.locale.format().timeZoneOffset, "hour")
|
this.timeZoneName
|
||||||
.toISOString();
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user