This commit is contained in:
@@ -214,6 +214,7 @@ export default {
|
||||
///////////////////////////////////////////
|
||||
// Get users default time zone
|
||||
//https://www.iana.org/time-zones
|
||||
//https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||
getTimeZoneName() {
|
||||
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
},
|
||||
@@ -316,6 +317,27 @@ export default {
|
||||
hour12: hour12
|
||||
});
|
||||
},
|
||||
///////////////////////////////////////////////
|
||||
// Convert a utc date to local time zone
|
||||
// and return time portion only in iso 8601
|
||||
// format (used by time and date picker components)
|
||||
//
|
||||
utcDateStringTo8601TimeOnlyString(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).toLocaleTimeString("sv-SE", {
|
||||
timeZone: timeZoneName
|
||||
});
|
||||
}
|
||||
},
|
||||
////////////////////////////////////////////////////////
|
||||
// dynamically set the vuetify language elements from
|
||||
// users localized text (am/pm etc)
|
||||
|
||||
Reference in New Issue
Block a user