Make sure the browser timezone is listed before preselecting it (otherwise use UTC)

This commit is contained in:
Alex Tselegidis 2022-10-05 12:09:57 +03:00
parent b204437473
commit 37b165f8a2

View file

@ -150,7 +150,9 @@ App.Pages.Booking = (function () {
}
});
$selectTimezone.val(Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC');
const browserTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
const isTimezoneSupported = $selectTimezone.find(`option[value="${browserTimezone}"]`).length > 0;
$selectTimezone.val(isTimezoneSupported ? browserTimezone : 'UTC');
// Bind the event handlers (might not be necessary every time we use this class).
addEventListeners();