This commit is contained in:
2020-02-07 00:01:57 +00:00
parent c7daec159a
commit 2e05fd48fa
2 changed files with 59 additions and 19 deletions

View File

@@ -322,7 +322,7 @@ export default {
// and return time portion only in iso 8601
// format (used by time and date picker components)
//
utcDateStringTo8601TimeOnlyString(value, timeZoneName) {
utcDateStringToLocal8601TimeOnlyString(value, timeZoneName) {
if (!value) {
//if no value, return the current time as expected by the time picker
} else {
@@ -355,6 +355,27 @@ export default {
.setZone("utc") //convert to UTC
.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
// users localized text (am/pm etc)