Fix report date rendering

This commit is contained in:
wuyanwanwu
2026-08-10 00:44:24 +08:00
parent 1e4adc63c0
commit c9db653aca
2 changed files with 11 additions and 2 deletions
+10 -1
View File
@@ -9,7 +9,16 @@ function today() {
const day = String(now.getDate()).padStart(2, '0'); const day = String(now.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`; 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)) : '近期'; } function formatTime(value) { return value ? new Intl.DateTimeFormat('zh-CN', { month: 'short', day: 'numeric' }).format(new Date(value)) : '近期'; }
async function loadHealth() { async function loadHealth() {
+1 -1
View File
@@ -215,7 +215,7 @@ async function listReports(query) {
const total = countResult.rows[0].count; const total = countResult.rows[0].count;
params.push(pageSize, (page - 1) * pageSize); params.push(pageSize, (page - 1) * pageSize);
const result = await pool.query(` 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, r.status, r.email_status, r.created_at,
COALESCE(json_agg(json_build_object( COALESCE(json_agg(json_build_object(
'id', a.id, 'title', a.title, 'translated_title', a.translated_title, 'id', a.id, 'title', a.title, 'translated_title', a.translated_title,