Skip to content

Commit b58f58e

Browse files
authored
Merge pull request #120 from Solux-WebBeing/fix/imminent
Fix/imminent
2 parents c911257 + c3504ad commit b58f58e

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

β€Žbackend/src/controllers/search.controller.jsβ€Ž

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,23 +106,45 @@ async function enrichDataWithMySQL(results, currentUserId = null) {
106106

107107
const totalCount = cheerMap[post.id] || 0;
108108
const specificInterestCount = (cheererInterestMap[post.id] && cheererInterestMap[post.id][displayTopic]) || 0;
109-
110-
// D-Day UI 계산
109+
// D-Day UI 계산 (KST κ°•μ œ 보정, 라이브러리 없이)
110+
// D-Day UI 계산 (KST κ°•μ œ 보정, 라이브러리 없이)
111111
let dDay = "μƒμ‹œ";
112112
let isTodayEnd = false;
113113

114114
if (post.end_date) {
115+
// πŸ”₯ ν•œκ΅­ ν˜„μž¬ μ‹œκ°„ λ§Œλ“€κΈ° (KST)
115116
const now = new Date();
116-
const endDate = new Date(post.end_date);
117+
const nowKST = new Date(now.getTime() + 9 * 60 * 60 * 1000);
118+
119+
// πŸ”₯ end_date λ¬Έμžμ—΄μ„ KST κΈ°μ€€μœΌλ‘œ μ•ˆμ „ νŒŒμ‹±
120+
// 예: "2026-01-24 15:00" β†’ "2026-01-24T15:00:00"
121+
let endStr = post.end_date;
122+
if (typeof endStr === "string" && endStr.includes(" ")) {
123+
endStr = endStr.replace(" ", "T");
124+
if (endStr.length === 16) endStr += ":00"; // 초 μ—†μœΌλ©΄ μΆ”κ°€
125+
}
126+
const endDate = new Date(endStr);
117127

118128
// πŸ”΄ 이미 μ‹œκ°„μ΄ μ§€λ‚œ 경우 β†’ 무쑰건 마감
119-
if (endDate.getTime() < now.getTime()) {
129+
if (endDate.getTime() < nowKST.getTime()) {
120130
dDay = "마감";
121131
isTodayEnd = false;
122132
} else {
123-
// 아직 μ•ˆ μ§€λ‚œ 경우 β†’ λ‚ μ§œ λ‹¨μœ„ D-Day 계산
124-
const todayMidnight = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();
125-
const endMidnight = new Date(endDate.getFullYear(), endDate.getMonth(), endDate.getDate()).getTime();
133+
// λ‚ μ§œ λ‹¨μœ„ D-Day 계산 (KST κΈ°μ€€)
134+
const todayMidnight = new Date(
135+
nowKST.getFullYear(),
136+
nowKST.getMonth(),
137+
nowKST.getDate(),
138+
0, 0, 0, 0
139+
).getTime();
140+
141+
const endMidnight = new Date(
142+
endDate.getFullYear(),
143+
endDate.getMonth(),
144+
endDate.getDate(),
145+
0, 0, 0, 0
146+
).getTime();
147+
126148
const diffDays = Math.ceil((endMidnight - todayMidnight) / (1000 * 60 * 60 * 24));
127149

128150
if (diffDays === 0) {
@@ -137,6 +159,7 @@ async function enrichDataWithMySQL(results, currentUserId = null) {
137159

138160

139161

162+
140163
return {
141164
id: post.id,
142165
title: post.title,

0 commit comments

Comments
Β (0)