diff --git a/frontend/issues-inbox.html b/frontend/issues-inbox.html index 8e5dddf..c409e18 100644 --- a/frontend/issues-inbox.html +++ b/frontend/issues-inbox.html @@ -386,6 +386,33 @@ let issues = []; let projects = []; let filteredIssues = []; + + // 한국 시간(KST) 유틸리티 함수 + function getKSTDate(date) { + const utcDate = new Date(date); + // UTC + 9시간 = KST + return new Date(utcDate.getTime() + (9 * 60 * 60 * 1000)); + } + + function formatKSTDate(date) { + const kstDate = getKSTDate(date); + return kstDate.toLocaleDateString('ko-KR', { timeZone: 'Asia/Seoul' }); + } + + function formatKSTTime(date) { + const kstDate = getKSTDate(date); + return kstDate.toLocaleTimeString('ko-KR', { + timeZone: 'Asia/Seoul', + hour: '2-digit', + minute: '2-digit' + }); + } + + function getKSTToday() { + const now = new Date(); + const kstNow = getKSTDate(now); + return new Date(kstNow.getFullYear(), kstNow.getMonth(), kstNow.getDate()); + } // 애니메이션 함수들 function animateHeaderAppearance() { @@ -639,8 +666,8 @@ container.innerHTML = filteredIssues.map(issue => { const project = projects.find(p => p.id === issue.project_id); const reportDate = new Date(issue.report_date); - const createdDate = reportDate.toLocaleDateString('ko-KR'); - const createdTime = reportDate.toLocaleTimeString('ko-KR', { hour: '2-digit', minute: '2-digit' }); + const createdDate = formatKSTDate(reportDate); + const createdTime = formatKSTTime(reportDate); const timeAgo = getTimeAgo(reportDate); // 사진 정보 처리 @@ -728,17 +755,18 @@ // 통계 로드 (새로운 기준) async function loadStatistics() { try { - // 현재 수신함 이슈들을 기반으로 통계 계산 - const today = new Date(); - const todayStart = new Date(today.getFullYear(), today.getMonth(), today.getDate()); + // 현재 수신함 이슈들을 기반으로 통계 계산 (KST 기준) + const todayStart = getKSTToday(); + console.log('📅 KST 기준 오늘 시작:', todayStart); // 전체: 수신함에 남아있는 목록 개수 (pending_review 상태) const totalCount = issues.length; - // 금일 신규: 오늘 올라온 목록 숫자 (확인된 것 포함) + // 금일 신규: 오늘 올라온 목록 숫자 (확인된 것 포함) - KST 기준 const todayNewCount = issues.filter(issue => { - const reportDate = new Date(issue.report_date); - return reportDate >= todayStart; + const reportDate = getKSTDate(new Date(issue.report_date)); + const reportDateOnly = new Date(reportDate.getFullYear(), reportDate.getMonth(), reportDate.getDate()); + return reportDateOnly >= todayStart; }).length; // 금일 처리: 오늘 처리된 건수 (API에서 가져와야 함) @@ -758,10 +786,11 @@ console.log('처리된 건수 조회 실패:', e); } - // 미해결: 오늘꺼 제외한 남아있는 것들 + // 미해결: 오늘꺼 제외한 남아있는 것들 - KST 기준 const unresolvedCount = issues.filter(issue => { - const reportDate = new Date(issue.report_date); - return reportDate < todayStart; + const reportDate = getKSTDate(new Date(issue.report_date)); + const reportDateOnly = new Date(reportDate.getFullYear(), reportDate.getMonth(), reportDate.getDate()); + return reportDateOnly < todayStart; }).length; // 통계 업데이트 @@ -770,11 +799,12 @@ document.getElementById('todayProcessedCount').textContent = todayProcessedCount; document.getElementById('unresolvedCount').textContent = unresolvedCount; - console.log('📊 통계 업데이트:', { + console.log('📊 통계 업데이트 (KST 기준):', { 전체: totalCount, 금일신규: todayNewCount, 금일처리: todayProcessedCount, - 미해결: unresolvedCount + 미해결: unresolvedCount, + 기준일: formatKSTDate(new Date()) }); } catch (error) { @@ -1062,8 +1092,9 @@ } function getTimeAgo(date) { - const now = new Date(); - const diffMs = now - date; + const now = getKSTDate(new Date()); + const kstDate = getKSTDate(date); + const diffMs = now - kstDate; const diffMins = Math.floor(diffMs / 60000); const diffHours = Math.floor(diffMs / 3600000); const diffDays = Math.floor(diffMs / 86400000); @@ -1072,7 +1103,7 @@ if (diffMins < 60) return `${diffMins}분 전`; if (diffHours < 24) return `${diffHours}시간 전`; if (diffDays < 7) return `${diffDays}일 전`; - return date.toLocaleDateString('ko-KR'); + return formatKSTDate(date); } function showLoading(show) {