From 474cba2182c49a92a7ab55f78f9bdf17e8017de3 Mon Sep 17 00:00:00 2001 From: Minseo Lee Date: Tue, 27 Aug 2024 17:49:59 +0900 Subject: [PATCH] Update useTimezone.ts --- src/components/hooks/useTimezone.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/components/hooks/useTimezone.ts b/src/components/hooks/useTimezone.ts index c74f513f5..f7976aabb 100644 --- a/src/components/hooks/useTimezone.ts +++ b/src/components/hooks/useTimezone.ts @@ -1,7 +1,8 @@ import { setItem } from 'next-basics'; import { TIMEZONE_CONFIG } from 'lib/constants'; -import { formatInTimeZone, zonedTimeToUtc, utcToZonedTime } from 'date-fns-tz'; +import { zonedTimeToUtc, utcToZonedTime } from 'date-fns-tz'; import useStore, { setTimezone } from 'store/app'; +import type { FormatDateOptions, IntlShape } from 'react-intl'; const selector = (state: { timezone: string }) => state.timezone; @@ -13,14 +14,8 @@ export function useTimezone() { setTimezone(value); }; - const formatTimezoneDate = (date: string, pattern: string) => { - return formatInTimeZone( - /^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]{3})?Z$/.test(date) - ? date - : date.split(' ').join('T') + 'Z', - timezone, - pattern, - ); + const formatTimezoneDate = (intl: IntlShape, date: string, options?: FormatDateOptions) => { + return intl.formatDate(date, options); }; const toUtc = (date: Date | string | number) => {