From 48c2f652c1eb287d66dc81640f72d3da69a1b2e5 Mon Sep 17 00:00:00 2001 From: Cecilia Liu Date: Wed, 9 Oct 2024 11:59:01 -0500 Subject: [PATCH] MAT-7679 add other supported time zones --- .../element/types/DateTimeComponent.tsx | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/components/editTestCase/qiCore/LeftPanel/ElementsTab/builder/element/types/DateTimeComponent.tsx b/src/components/editTestCase/qiCore/LeftPanel/ElementsTab/builder/element/types/DateTimeComponent.tsx index 8e461254c..a5f40485e 100644 --- a/src/components/editTestCase/qiCore/LeftPanel/ElementsTab/builder/element/types/DateTimeComponent.tsx +++ b/src/components/editTestCase/qiCore/LeftPanel/ElementsTab/builder/element/types/DateTimeComponent.tsx @@ -25,17 +25,27 @@ interface MenuObj { label: string; } const options: MenuObj[] = [ + { value: "America/Puerto_Rico", label: "AST" }, { value: "America/New_York", label: "EST" }, { value: "America/Chicago", label: "CST" }, { value: "America/Denver", label: "MST" }, { value: "America/Los_Angeles", label: "PST" }, + { value: "America/Anchorage", label: "AKST" }, + { value: "America/honolulu", label: "HST" }, + { value: "America/American_Samoa", label: "WST" }, + { value: "America/Saipan", label: "CHST" }, ]; const offSets = [ + { id: "America/Puerto_Rico - AST", value: "-04:00" }, { id: "America/New_York - EST", value: "-05:00" }, { id: "America/Chicago - CST", value: "-06:00" }, { id: "America/Denver - MST", value: "-07:00" }, { id: "America/Los_Angeles - PST", value: "-08:00" }, + { id: "America/Anchorage - AKST", value: "-09:00" }, + { id: "America/honolulu - HST", value: "-10:00" }, + { id: "America/American_Samoa - WST", value: "-11:00" }, + { id: "America/Saipan - CHST", value: "+10:00" }, ]; const findByLabel = (value) => { @@ -65,6 +75,18 @@ const getOffSet = (value) => { return result; }; +const findByOffSet = (value) => { + let result = "America/New_York - EST"; + if (value) { + offSets.forEach((opt) => { + if (opt.value === value) { + result = opt.id; + } + }); + } + return result; +}; + const DateTimeComponent = ({ canEdit, fieldRequired, @@ -99,6 +121,9 @@ const DateTimeComponent = ({ converted = convertToStandardTime(converted).tz(userTimeZone); setTimeZone(findByLabel(timezoneName.replace("D", "S"))); + } else if (timezoneName.includes("GMT")) { + const zone = findByOffSet(timezoneName.substring(3, 6) + ":00"); + setTimeZone(zone); } else { setTimeZone(findByLabel(timezoneName)); }