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": { "rssiBar": {
"tooltip": "Werte > -67 dBm gelten als gut. > -30 dBm ist erstaunlich" "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": { "rssiBar": {
"tooltip": "Values > -67 dBm are considered good. > -30 dBm is amazing" "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": { "rssiBar": {
"tooltip": "Se consideran buenos valores > -67 dBm. > -30 dBm es increíble" "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": { "rssiBar": {
"tooltip": "Waarden > -67 dBm zijn goed. > -30 dBm is verbazingwekkend" "tooltip": "Waarden > -67 dBm zijn goed. > -30 dBm is verbazingwekkend"
}, },
"warning": "Waarschuwing" "warning": "Waarschuwing",
"auto-detect": "Automatische detectie"
} }

View file

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

View file

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