Auto-detect timezone offset from system

This commit is contained in:
Djuri Baars 2024-06-24 13:58:01 +02:00
parent 2b2c8e7fc7
commit fd76caa6f4
6 changed files with 22 additions and 7 deletions

View File

@ -100,5 +100,6 @@
"rssiBar": {
"tooltip": "Werte > -67 dBm gelten als gut. > -30 dBm ist erstaunlich"
},
"warning": "Achtung"
"warning": "Achtung",
"auto-detect": "Automatische Erkennung"
}

View File

@ -102,5 +102,6 @@
"rssiBar": {
"tooltip": "Values > -67 dBm are considered good. > -30 dBm is amazing"
},
"warning": "Warning"
"warning": "Warning",
"auto-detect": "Auto-detect"
}

View File

@ -99,5 +99,6 @@
"rssiBar": {
"tooltip": "Se consideran buenos valores > -67 dBm. > -30 dBm es increíble"
},
"warning": "Aviso"
"warning": "Aviso",
"auto-detect": "Detección automática"
}

View File

@ -99,5 +99,6 @@
"rssiBar": {
"tooltip": "Waarden > -67 dBm zijn goed. > -30 dBm is verbazingwekkend"
},
"warning": "Waarschuwing"
"warning": "Waarschuwing",
"auto-detect": "Automatische detectie"
}

View File

@ -43,10 +43,12 @@
let languageNames = {};
locale.subscribe(() => {
let newLanguageNames = new Intl.DisplayNames([$locale], { type: 'language' });
if ($locale) {
let newLanguageNames = new Intl.DisplayNames([$locale], { type: 'language' });
for (let l: string of $locales) {
languageNames[l] = newLanguageNames.of(l);
for (let l: string of $locales) {
languageNames[l] = newLanguageNames.of(l);
}
}
});
</script>

View File

@ -43,6 +43,12 @@
dispatch('formReset');
};
const getTzOffsetFromSystem = () => {
const dt = new Date();
let diffTZ = dt.getTimezoneOffset();
$settings.tzOffset = diffTZ * -1;
};
const onSave = async (e: Event) => {
e.preventDefault();
let formSettings = $settings;
@ -191,6 +197,9 @@
bind:value={$settings.tzOffset}
/>
<InputGroupText>{$_('time.minutes')}</InputGroupText>
<Button type="button" color="info" on:click={getTzOffsetFromSystem}
>{$_('auto-detect')}</Button
>
</InputGroup>
<FormText>{$_('section.settings.tzOffsetHelpText')}</FormText>
</Col>