From 35b8fec96c3fb54ccb6cd6e29e81619f8964585f Mon Sep 17 00:00:00 2001 From: shangzy Date: Tue, 7 Apr 2026 15:50:30 +0800 Subject: [PATCH] fix: use toISOString for trend date serialization to prevent year 2001 bug pg driver returns PostgreSQL date as JS Date object. String(date).slice(0,10) produced "Mon Apr 07" instead of "2026-04-07", causing chart tooltips to default to year 2001 when parsed by new Date(). --- lib/queries.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/queries.ts b/lib/queries.ts index 3a81039..0f46513 100644 --- a/lib/queries.ts +++ b/lib/queries.ts @@ -107,7 +107,7 @@ export async function getTrends( ); return rows.map((r) => ({ - date: String(r.date).slice(0, 10), + date: r.date instanceof Date ? r.date.toISOString().slice(0, 10) : String(r.date).slice(0, 10), calls: Number(r.calls), prompt_tokens: Number(r.prompt_tokens), completion_tokens: Number(r.completion_tokens),