From b3a5d868a74029885e2e15f8b1251e1c2f05b69b Mon Sep 17 00:00:00 2001 From: LouisLam Date: Tue, 13 Jul 2021 17:46:39 +0800 Subject: [PATCH] catch timezone error if browser do not have --- src/util-frontend.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/util-frontend.js b/src/util-frontend.js index 35c8ed63c..ac308a8ec 100644 --- a/src/util-frontend.js +++ b/src/util-frontend.js @@ -362,22 +362,29 @@ const aryIannaTimeZones = [ 'Pacific/Efate', 'Pacific/Wallis', 'Pacific/Apia', - 'Africa/Johannesburg' + 'Africa/Johannesburg', ]; export function timezoneList() { + let result = []; for (let timezone of aryIannaTimeZones) { - let display = dayjs().tz(timezone).format("Z"); + try { + let display = dayjs().tz(timezone).format("Z"); + + result.push({ + name: `(UTC${display}) ${timezone}`, + value: timezone, + time: getTimezoneOffset(timezone), + }) + } catch (e) { + console.log(e.message); + console.log("Skip this timezone") + } - result.push({ - name: `(UTC${display}) ${timezone}`, - value: timezone, - time: getTimezoneOffset(timezone), - }) } result.sort((a, b) => {