This commit is contained in:
2020-02-06 23:01:29 +00:00
parent 2e8d6945f7
commit 742fad6125
3 changed files with 31 additions and 3 deletions

View File

@@ -75,6 +75,8 @@ TODO: LOCALIZATION
- Make functional user settings form so can test shit out
- Need override for locale, currency setting, 12hr clock etc etc
- Need a browser check on opening the login page that will check to ensure the browser can do the date conversions properly etc and tell user browser is unsuitable if it isn't
- TRY AN ALTERNATE LANGUAGE IN VUETIFY USING THEIR METHOD, SEE WHATS INVOLVED
- Find out how to override the default locale for vuetify to set specific items to our localized text version
- this saves having to use a whole locale for just the calendar etc

View File

@@ -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)

View File

@@ -229,16 +229,20 @@ export default {
//-----------------
//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"}));
get() {
if (this.value) {
console.log(this.value.substr(11, 8));
return this.value.substr(11, 8);
//Ok, this looks weird but sv-SE is the same format as iso8601 format required so if this breaks that's why
return new Date(this.value).toLocaleTimeString("sv-SE", {
timeZone: this.timeZoneName
});
} else {
return "";
}
},
set(value) {
this.value = value;
//this.value = value;
}
}
}