From c9db653acae3fad6de80a6769be53d4381f6dcdc Mon Sep 17 00:00:00 2001 From: wuyanwanwu <104009119+wuyanwanwu@users.noreply.github.com.> Date: Mon, 10 Aug 2026 00:44:24 +0800 Subject: [PATCH] Fix report date rendering --- web/public/app.js | 11 ++++++++++- web/server.js | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/web/public/app.js b/web/public/app.js index 7a15f75..2b28a5c 100644 --- a/web/public/app.js +++ b/web/public/app.js @@ -9,7 +9,16 @@ function today() { const day = String(now.getDate()).padStart(2, '0'); return `${year}-${month}-${day}`; } -function formatDate(value) { return value ? new Intl.DateTimeFormat('zh-CN', { year: 'numeric', month: 'long', day: 'numeric', weekday: 'short' }).format(new Date(`${value}T00:00:00`)) : 'β€”'; } +function formatDate(value) { + if (!value) return 'β€”'; + const match = String(value).match(/^(\d{4})-(\d{2})-(\d{2})/); + if (!match) return String(value); + const [, year, month, day] = match; + const date = new Date(Number(year), Number(month) - 1, Number(day)); + return new Intl.DateTimeFormat('zh-CN', { + year: 'numeric', month: 'long', day: 'numeric', weekday: 'short', + }).format(date); +} function formatTime(value) { return value ? new Intl.DateTimeFormat('zh-CN', { month: 'short', day: 'numeric' }).format(new Date(value)) : 'θΏ‘ζœŸ'; } async function loadHealth() { diff --git a/web/server.js b/web/server.js index faf4129..388804c 100644 --- a/web/server.js +++ b/web/server.js @@ -215,7 +215,7 @@ async function listReports(query) { const total = countResult.rows[0].count; params.push(pageSize, (page - 1) * pageSize); const result = await pool.query(` - SELECT r.id, r.report_date, r.title, r.introduction, r.item_count, + SELECT r.id, r.report_date::text AS report_date, r.title, r.introduction, r.item_count, r.status, r.email_status, r.created_at, COALESCE(json_agg(json_build_object( 'id', a.id, 'title', a.title, 'translated_title', a.translated_title,