From 1638ded20d2cb26358c5070e995a0d882de82a8c Mon Sep 17 00:00:00 2001 From: DJDavid98 Date: Thu, 16 Sep 2021 21:13:00 +0200 Subject: [PATCH] Give non-misleading labels to Etc/GMT timezone options Closes #12 --- src/components/TimestampPicker.tsx | 10 +++++----- src/pages/index.tsx | 24 ++++++++--------------- src/util/timezone.ts | 31 ++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 21 deletions(-) create mode 100644 src/util/timezone.ts diff --git a/src/components/TimestampPicker.tsx b/src/components/TimestampPicker.tsx index 8b766d0..22710ec 100644 --- a/src/components/TimestampPicker.tsx +++ b/src/components/TimestampPicker.tsx @@ -2,12 +2,13 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { TFunction } from 'i18next'; import styles from 'modules/TimestampPicker.module.scss'; import moment, { Moment } from 'moment-timezone'; -import { useCallback, VFC } from 'react'; +import { useCallback, useMemo, VFC } from 'react'; import Datetime from 'react-datetime'; import Select from 'react-select'; import { StylesConfig } from 'react-select/src/styles'; import { ThemeConfig } from 'react-select/src/theme'; import { Col, FormGroup, Input, InputGroup, InputGroupAddon, InputGroupText, Label, Row } from 'reactstrap'; +import { getTimezoneValue } from 'src/util/timezone'; const dateInputId = 'date-input'; const timezoneSelectId = 'timezone-input'; @@ -109,6 +110,8 @@ export const TimestampPicker: VFC = ({ // eslint-disable-next-line @typescript-eslint/no-explicit-any const renderDateInput = useCallback((props: any) => , []); + const timezoneSelectValue = useMemo(() => getTimezoneValue(timezone), [timezone]); + return (
@@ -136,10 +139,7 @@ export const TimestampPicker: VFC = ({