forked from btclock/webui
Auto-detect timezone offset from system
This commit is contained in:
parent
2b2c8e7fc7
commit
fd76caa6f4
6 changed files with 22 additions and 7 deletions
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue