This commit is contained in:
2020-02-07 00:15:05 +00:00
parent c7a9cdc8ee
commit 13defdff1d

View File

@@ -40,23 +40,13 @@
/* 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 */
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: () => ({
date: null,
oldDate: null,
dlgdate: false,
//cache display format stuff
timeZoneName: window.$gz.locale.getTimeZoneName(),
languageName: window.$gz.locale.getBrowserLanguages(),
defaultLocale: window.$gz.locale.getBrowserFirstLanguage().split("-", 1)[0]
}),
props: {
@@ -96,72 +86,57 @@ export default {
},
computed: {
formatDateTime() {
return this.value
? window.$gz.dayjs
.utc(this.value)
.add(window.$gz.locale.format().timeZoneOffset, "hour")
.format(window.$gz.locale.format().shortDateAndTime)
: "";
return window.$gz.locale.utcDateToShortDateAndTimeLocalized(
this.value,
this.timeZoneName,
this.languageName,
this.hour12
);
},
formatDate() {
return this.value
? window.$gz.dayjs
.utc(this.value)
.add(window.$gz.locale.format().timeZoneOffset, "hour")
.format(window.$gz.locale.format().shortDate)
: "";
return window.$gz.locale.utcDateToShortDateLocalized(
this.value,
this.timeZoneName,
this.languageName
);
},
formatTime() {
return this.value
? window.$gz.dayjs
.utc(this.value)
.add(window.$gz.locale.format().timeZoneOffset, "hour")
.format(window.$gz.locale.format().shortTime)
: "";
return window.$gz.locale.utcDateToShortTimeLocalized(
this.value,
this.timeZoneName,
this.languageName,
this.hour12
);
},
dateOnly: {
get() {
//TODO: this will likely need an improvement for forms where there should be an automatic pre-set time chosen like workorder labor;
var defaultDateString = window.$gz
.dayjs()
.utc()
.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;
//return date only portion converted to local working time zone: YYYY-MM-DD
return window.$gz.locale.utcDateStringToLocal8601DateOnlyString(
this.value,
this.timeZoneName
);
},
set(value) {
this.date = window.$gz.dayjs
.utc(value + " " + this.timeOnly)
.subtract(window.$gz.locale.format().timeZoneOffset, "hour")
.toISOString();
this.date = window.$gz.locale.localTimeDateStringToUTC8601String(
value + "T" + this.timeOnly,
this.timeZoneName
);
}
},
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() {
//TODO: this will likely need an improvement for forms where there should be an automatic pre-set time chosen like workorder labor;
var defaultTimeString = window.$gz.dayjs
.utc()
.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;
return window.$gz.locale.utcDateStringToLocal8601TimeOnlyString(
this.value,
this.timeZoneName
);
},
set(value) {
this.date = window.$gz.dayjs
.utc(this.dateOnly + " " + value)
.subtract(window.$gz.locale.format().timeZoneOffset, "hour")
.toISOString();
this.date = window.$gz.locale.localTimeDateStringToUTC8601String(
this.dateOnly + "T" + value,
this.timeZoneName
);
}
}
}