This commit is contained in:
@@ -338,6 +338,23 @@ export default {
|
||||
});
|
||||
}
|
||||
},
|
||||
///////////////////////////////////////////////
|
||||
// Convert a local time only string with date string
|
||||
// to UTC and output as ISO 8601
|
||||
// (used by time and date picker components)
|
||||
//
|
||||
localTimeDateStringToUTC8601String(value, timeZoneName) {
|
||||
//https://moment.github.io/luxon/docs/manual/zones.html#creating-datetimes-in-a-zone
|
||||
if (!timeZoneName) {
|
||||
timeZoneName = this.getTimeZoneName();
|
||||
}
|
||||
//parse in the time in the currently used timezone
|
||||
return window.$gz.DateTime.fromISO(value, {
|
||||
zone: this.timeZoneName
|
||||
})
|
||||
.setZone("utc") //convert to UTC
|
||||
.toISO(); //output as ISO 8601
|
||||
},
|
||||
////////////////////////////////////////////////////////
|
||||
// dynamically set the vuetify language elements from
|
||||
// users localized text (am/pm etc)
|
||||
|
||||
@@ -204,45 +204,27 @@ export default {
|
||||
}
|
||||
},
|
||||
timeOnly: {
|
||||
//The control needs this value in ISO 8601 format but adjusted to user time zone
|
||||
//------------originally
|
||||
// get() {
|
||||
// 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;
|
||||
// },
|
||||
// set(value) {
|
||||
// this.date = window.$gz.dayjs
|
||||
// .utc(this.dateOnly + " " + value)
|
||||
// .subtract(window.$gz.locale.format().timeZoneOffset, "hour")
|
||||
// .toISOString();
|
||||
// }
|
||||
|
||||
//-----------------
|
||||
//expects just the hours minutes seconds portion: 18:18:49
|
||||
//TODO: Need to convert to desired time zone first or the control will show the UTC time instead
|
||||
//console.log(new Date().toLocaleTimeString('sv-SE',{timeZone:"America/Vancouver"}));
|
||||
//console.log(new Date().toLocaleTimeString('sv-SE',{timeZone:"UTC"}));
|
||||
//Needs to convert into and out of the desired time zone or the control will show the UTC time instead
|
||||
get() {
|
||||
return window.$gz.locale.utcDateStringTo8601TimeOnlyString(this.value);
|
||||
return window.$gz.locale.utcDateStringTo8601TimeOnlyString(
|
||||
this.value,
|
||||
this.timeZoneName
|
||||
);
|
||||
},
|
||||
set(value) {
|
||||
//https://moment.github.io/luxon/docs/manual/zones.html#creating-datetimes-in-a-zone
|
||||
this.date = window.$gz.locale.localTimeDateStringToUTC8601String(
|
||||
this.dateOnly + "T" + value,
|
||||
this.timeZoneName
|
||||
);
|
||||
// //https://moment.github.io/luxon/docs/manual/zones.html#creating-datetimes-in-a-zone
|
||||
|
||||
//parse in the time in the currently used timezone
|
||||
this.date = window.$gz.DateTime.fromISO(this.dateOnly + "T" + value, {
|
||||
zone: this.timeZoneName
|
||||
})
|
||||
.setZone("utc") //convert to UTC
|
||||
.toISO(); //output as ISO 8601
|
||||
// //parse in the time in the currently used timezone
|
||||
// this.date = window.$gz.DateTime.fromISO(this.dateOnly + "T" + value, {
|
||||
// zone: this.timeZoneName
|
||||
// })
|
||||
// .setZone("utc") //convert to UTC
|
||||
// .toISO(); //output as ISO 8601
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user