Skip to content

Commit

Permalink
fix(ui): validate timezone on ui
Browse files Browse the repository at this point in the history
Fixes #3807
  • Loading branch information
robertsLando committed Jul 16, 2024
1 parent a609451 commit 1c315ea
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/stores/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,19 @@ const useBaseStore = defineStore('base', {
init(data) {
if (data) {
if (data.tz) {
this.tz = data.tz
// validate timezone
try {
new Intl.DateTimeFormat(undefined, {
timeZone: data.tz,
})
this.tz = data.tz
} catch (e) {
log.error('Invalid timezone:', data.tz)
this.showSnackbar(
`Invalid timezone: ${data.tz}`,
'error',
)
}
}

if (data.locale) {
Expand Down

0 comments on commit 1c315ea

Please sign in to comment.