From a0c2aa04ad92c6a937a09d7affb49b8c482cdc43 Mon Sep 17 00:00:00 2001 From: khj0414 Date: Fri, 4 Apr 2025 13:22:16 +0900 Subject: [PATCH] =?UTF-8?q?=ED=88=AC=ED=91=9C=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/main/MainVote.vue | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/main/MainVote.vue b/src/components/main/MainVote.vue index eca0bf5..c8d521b 100644 --- a/src/components/main/MainVote.vue +++ b/src/components/main/MainVote.vue @@ -28,8 +28,11 @@
{{ truncateTitle(item.localVote.LOCVOTTTL) }}
- - {{getDaysAgo(item.localVote.formatted_LOCVOTEDT)}}({{item.localVote.total_voted}}/{{ item.localVote.total_votable }}) + + + ⏰{{getDaysAgo(item.localVote.formatted_LOCVOTEDT)}} ({{item.localVote.total_voted}}/{{ item.localVote.total_votable }}) + @@ -222,14 +225,15 @@ const getDaysAgo = (dateString) => { const inputDate = new Date(dateString); // 문자열을 Date 객체로 변환 const today = new Date(); // 현재 날짜 가져오기 - // 날짜 차이 계산 (밀리초 기준) - const timeDiff = today - inputDate; - const dayDiff = Math.floor(timeDiff / (1000 * 60 * 60 * 24))+1; // 일 단위 변환 + const input = new Date(inputDate.getFullYear(), inputDate.getMonth(), inputDate.getDate()); + const now = new Date(today.getFullYear(), today.getMonth(), today.getDate()); + const timeDiff = now - input; + const dayDiff = Math.floor(timeDiff / (1000 * 60 * 60 * 24)); // 오늘 날짜인 경우 "오늘" 반환 - if (dayDiff === 0) return "⏰금일 종료"; + if (dayDiff === 0) return "금일 종료"; - return `⏰종료 ${Math.abs(dayDiff)}일 전`; + return `종료 ${Math.abs(dayDiff)}일 전`; };