From 37b165f8a2f6331300081d89747ff32fe6b3fce7 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Wed, 5 Oct 2022 12:09:57 +0300 Subject: [PATCH] Make sure the browser timezone is listed before preselecting it (otherwise use UTC) --- assets/js/pages/booking.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/assets/js/pages/booking.js b/assets/js/pages/booking.js index 87f374be..0f97f2cd 100644 --- a/assets/js/pages/booking.js +++ b/assets/js/pages/booking.js @@ -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();