fix: kline time display in Beijing time (UTC+8)
This commit is contained in:
parent
072592145f
commit
4f0cc7c393
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user