fix: show nextFundingTime in Beijing time, add 明天 prefix if next day
This commit is contained in:
parent
362c1f1e16
commit
88543efe5c
@ -19,9 +19,16 @@ export default function RateCard({ asset, data }: Props) {
|
||||
? "bg-emerald-50 text-emerald-700 border border-emerald-200"
|
||||
: "bg-red-50 text-red-600 border border-red-200";
|
||||
|
||||
const nextTime = data?.nextFundingTime
|
||||
? new Date(data.nextFundingTime).toLocaleTimeString("zh-CN", { hour: "2-digit", minute: "2-digit" })
|
||||
: "--";
|
||||
const nextTime = (() => {
|
||||
if (!data?.nextFundingTime) return "--";
|
||||
// 转北京时间(UTC+8)
|
||||
const ts = data.nextFundingTime;
|
||||
const bjt = new Date(ts + 8 * 3600 * 1000);
|
||||
const now = new Date(Date.now() + 8 * 3600 * 1000);
|
||||
const isToday = bjt.getUTCDate() === now.getUTCDate() && bjt.getUTCMonth() === now.getUTCMonth();
|
||||
const hhmm = `${String(bjt.getUTCHours()).padStart(2,"0")}:${String(bjt.getUTCMinutes()).padStart(2,"0")}`;
|
||||
return isToday ? hhmm : `明天 ${hhmm}`;
|
||||
})();
|
||||
|
||||
return (
|
||||
<div className="rounded-xl border border-slate-200 bg-white shadow-sm p-6 space-y-4">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user