This commit is contained in:
@@ -322,7 +322,7 @@ export default {
|
|||||||
// and return time portion only in iso 8601
|
// and return time portion only in iso 8601
|
||||||
// format (used by time and date picker components)
|
// format (used by time and date picker components)
|
||||||
//
|
//
|
||||||
utcDateStringTo8601TimeOnlyString(value, timeZoneName) {
|
utcDateStringToLocal8601TimeOnlyString(value, timeZoneName) {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
//if no value, return the current time as expected by the time picker
|
//if no value, return the current time as expected by the time picker
|
||||||
} else {
|
} else {
|
||||||
@@ -355,6 +355,27 @@ export default {
|
|||||||
.setZone("utc") //convert to UTC
|
.setZone("utc") //convert to UTC
|
||||||
.toISO(); //output as ISO 8601
|
.toISO(); //output as ISO 8601
|
||||||
},
|
},
|
||||||
|
///////////////////////////////////////////////
|
||||||
|
// Convert a utc date to local time zone
|
||||||
|
// and return date only portion only in iso 8601
|
||||||
|
// format (used by time and date picker components)
|
||||||
|
//
|
||||||
|
utcDateStringToLocal8601DateOnlyString(value, timeZoneName) {
|
||||||
|
if (!value) {
|
||||||
|
//if no value, return the current time as expected by the time picker
|
||||||
|
} else {
|
||||||
|
//ok, the reason for sv-SE is that it's a locale that returns the time already in ISO format and 24hr by default
|
||||||
|
//that can change over time so if this breaks that's why
|
||||||
|
//also fr-CA does as well as possibly en-CA
|
||||||
|
//https://stackoverflow.com/a/58633686/8939
|
||||||
|
if (!timeZoneName) {
|
||||||
|
timeZoneName = this.getTimeZoneName();
|
||||||
|
}
|
||||||
|
return new Date(value).toLocaleDateString("sv-SE", {
|
||||||
|
timeZone: timeZoneName
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
// dynamically set the vuetify language elements from
|
// dynamically set the vuetify language elements from
|
||||||
// users localized text (am/pm etc)
|
// users localized text (am/pm etc)
|
||||||
|
|||||||
@@ -181,33 +181,52 @@ export default {
|
|||||||
// : "";
|
// : "";
|
||||||
},
|
},
|
||||||
dateOnly: {
|
dateOnly: {
|
||||||
get() {
|
//----------------------------
|
||||||
//TODO: this will likely need an improvement for forms where there should be an automatic pre-set time chosen like workorder labor;
|
// get() {
|
||||||
var defaultDateString = window.$gz
|
// //TODO: this will likely need an improvement for forms where there should be an automatic pre-set time chosen like workorder labor;
|
||||||
.dayjs()
|
// var defaultDateString = window.$gz
|
||||||
.utc()
|
// .dayjs()
|
||||||
.add(window.$gz.locale.format().timeZoneOffset, "hour")
|
// .utc()
|
||||||
.format("YYYY-MM-DD");
|
// .add(window.$gz.locale.format().timeZoneOffset, "hour")
|
||||||
|
// .format("YYYY-MM-DD");
|
||||||
|
|
||||||
return this.value
|
// return this.value
|
||||||
? window.$gz.dayjs
|
// ? window.$gz.dayjs
|
||||||
.utc(this.value)
|
// .utc(this.value)
|
||||||
.add(window.$gz.locale.format().timeZoneOffset, "hour")
|
// .add(window.$gz.locale.format().timeZoneOffset, "hour")
|
||||||
.format("YYYY-MM-DD")
|
// .format("YYYY-MM-DD")
|
||||||
: defaultDateString;
|
// : defaultDateString;
|
||||||
|
// },
|
||||||
|
// set(value) {
|
||||||
|
// this.date = window.$gz.dayjs
|
||||||
|
// .utc(value + " " + this.timeOnly)
|
||||||
|
// .subtract(window.$gz.locale.format().timeZoneOffset, "hour")
|
||||||
|
// .toISOString();
|
||||||
|
// }
|
||||||
|
//---------------------------
|
||||||
|
get() {
|
||||||
|
//TODO: return date only portion converted to local working time zone: YYYY-MM-DD
|
||||||
|
|
||||||
|
var v = window.$gz.locale.utcDateStringToLocal8601DateOnlyString(
|
||||||
|
this.value,
|
||||||
|
this.timeZoneName
|
||||||
|
);
|
||||||
|
console.log(this.value);
|
||||||
|
console.log(v);
|
||||||
|
return v;
|
||||||
},
|
},
|
||||||
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
|
//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
|
//Needs to convert into and out of the desired time zone or the control will show the UTC time instead
|
||||||
get() {
|
get() {
|
||||||
return window.$gz.locale.utcDateStringTo8601TimeOnlyString(
|
return window.$gz.locale.utcDateStringToLocal8601TimeOnlyString(
|
||||||
this.value,
|
this.value,
|
||||||
this.timeZoneName
|
this.timeZoneName
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user