Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/feature/photo-detail/components/SectionPhotoData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@
onAfterDelete?: () => void;
}

// 촬영 시각: 사진 EXIF 시간 그대로 표시 (타임존 변환 안 함)
const formatCaptureTime = (isoString?: string): string => {
if (!isoString) return '';

// ISO 문자열에서 직접 파싱 (타임존 변환 없이)
const match = isoString.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/);

Check failure on line 18 in src/feature/photo-detail/components/SectionPhotoData.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/` with `⏎····/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/,⏎··`
if (!match) return '정보 없음';

const [, year, month, day, hour, minute] = match;

return `${year}${month}${day}${hour}${minute}분`;
};
Comment on lines 14 to 26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

안녕하세요! formatCaptureTime 함수 구현 잘 보았습니다.

현재 정규식은 YYYY-MM-DDTHH:mm:ss 형식을 기대하고 있어, 초(second) 정보가 없거나 날짜만 있는 ISO 문자열(YYYY-MM-DD)이 들어올 경우 의도치 않게 '정보 없음'을 반환할 수 있습니다.

조금 더 유연하게 다양한 ISO 날짜 형식에 대응할 수 있도록 아래와 같이 개선하는 것을 제안합니다. 이 코드는 시간 정보가 없는 경우 날짜만 표시하고, 초 정보는 무시하여 더 안정적으로 동작합니다.

const formatCaptureTime = (isoString?: string): string => {
  if (!isoString) return '';

  // ISO 문자열에서 직접 파싱 (타임존 변환 없이)
  // YYYY-MM-DD 또는 YYYY-MM-DDTHH:mm... 형식을 지원합니다.
  const match = isoString.match(/^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2}))?/);
  if (!match) return '정보 없음';

  const [, year, month, day, hour, minute] = match;

  if (hour !== undefined && minute !== undefined) {
    return `${year}년 ${month}월 ${day}일 ${hour}시 ${minute}분`;
  }

  return `${year}년 ${month}월 ${day}일`;
};


// 업로드 시각: UTC를 로컬 시간(KST)으로 변환
const formatKoreanDateTime = (isoString?: string): string => {
if (!isoString) return '';

Expand Down Expand Up @@ -65,7 +79,7 @@
<div className='flex items-center justify-between'>
<dt className='text-text-subtle w-1/3'>촬영 시각</dt>
<dd className='text-text-subtler flex-1'>
{formatKoreanDateTime(data?.captureTime)}
{formatCaptureTime(data?.captureTime)}
</dd>
</div>
<div className='flex items-center justify-between'>
Expand Down
Loading