Skip to content

Commit

Permalink
날짜 오류 수정 (#42)
Browse files Browse the repository at this point in the history
* fix: 날짜 형식 UTC로 변환

* fix: 날짜 형식 UTC로 변환
  • Loading branch information
minh0518 authored Mar 1, 2024
1 parent 7249b6b commit d743c8a
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,17 @@ const UploadDeadlineDate = forwardRef<HTMLInputElement, UploadDeadlineDateProps>

// 리액트 캘린더 전용 업데이트 함수
const setDate: Dispatch<SetStateAction<Value>> = (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],
Expand Down

0 comments on commit d743c8a

Please sign in to comment.