From 4f0cc7c3932b8be8363fd4f6386f86c6830a2703 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 27 Feb 2026 06:44:58 +0000 Subject: [PATCH] fix: kline time display in Beijing time (UTC+8) --- frontend/app/kline/page.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/frontend/app/kline/page.tsx b/frontend/app/kline/page.tsx index 1cfcc3f..804529a 100644 --- a/frontend/app/kline/page.tsx +++ b/frontend/app/kline/page.tsx @@ -39,10 +39,28 @@ function chartOptions(height: number) { horzLines: { color: "#f1f5f9" }, }, crosshair: { mode: 1 }, + localization: { + timeFormatter: (ts: number) => { + // UTC+8 北京时间 + const d = new Date((ts + 8 * 3600) * 1000); + const Y = d.getUTCFullYear(); + const M = String(d.getUTCMonth() + 1).padStart(2, "0"); + const D = String(d.getUTCDate()).padStart(2, "0"); + const h = String(d.getUTCHours()).padStart(2, "0"); + const m = String(d.getUTCMinutes()).padStart(2, "0"); + return `${Y}-${M}-${D} ${h}:${m}`; + }, + }, timeScale: { borderColor: "#e2e8f0", timeVisible: true, secondsVisible: false, + tickMarkFormatter: (ts: number) => { + const d = new Date((ts + 8 * 3600) * 1000); + const h = String(d.getUTCHours()).padStart(2, "0"); + const m = String(d.getUTCMinutes()).padStart(2, "0"); + return `${h}:${m}`; + }, }, rightPriceScale: { borderColor: "#e2e8f0" }, height,