From d743c8aa4b21a61bc643d0360e4a3775d6795095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EB=AF=BC=ED=98=B8?= <78631876+minh0518@users.noreply.github.com> Date: Fri, 1 Mar 2024 21:52:24 +0900 Subject: [PATCH] =?UTF-8?q?=EB=82=A0=EC=A7=9C=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20(#42)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 날짜 형식 UTC로 변환 * fix: 날짜 형식 UTC로 변환 --- .../upload/[id]/_component/UploadDeadlineDate.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/(afterlogin)/upload/[id]/_component/UploadDeadlineDate.tsx b/src/app/(afterlogin)/upload/[id]/_component/UploadDeadlineDate.tsx index 8462587..8994e56 100644 --- a/src/app/(afterlogin)/upload/[id]/_component/UploadDeadlineDate.tsx +++ b/src/app/(afterlogin)/upload/[id]/_component/UploadDeadlineDate.tsx @@ -33,11 +33,17 @@ const UploadDeadlineDate = forwardRef // 리액트 캘린더 전용 업데이트 함수 const setDate: Dispatch> = (newValue) => { + // KST를 UTC로 변환하기 위해, getTimezoneOffset()의 결과를 반전시키고 9시간(한국 시간대)을 더함 + // (년,월,일만 적용) + const targetDate = newValue as Date; + const utcDate = new Date( + targetDate.getTime() - targetDate.getTimezoneOffset() * 60000 + 9 * 60 * 60000, + ); + setPresentationData((prev) => { const shallow = { ...prev }; shallow.title = getValues('title'); - shallow.deadlineDate = - newValue instanceof Function ? newValue(prev.deadlineDate) : newValue; + shallow.deadlineDate = newValue instanceof Function ? newValue(prev.deadlineDate) : utcDate; const shallowSlides = [...shallow.slides]; shallowSlides[currentPageIndex] = { ...shallowSlides[currentPageIndex],