总览北京时间改为更易读的纯文本样式,日期格式与拉取时间一致。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-03 03:28:56 +08:00
parent 6d750d0e3f
commit 446fb1a1f3
3 changed files with 61 additions and 24 deletions
+26 -5
View File
@@ -333,7 +333,7 @@
function formatBeijingNow() {
try {
return new Intl.DateTimeFormat("zh-CN", {
const parts = new Intl.DateTimeFormat("en-CA", {
timeZone: "Asia/Shanghai",
year: "numeric",
month: "2-digit",
@@ -342,7 +342,26 @@
minute: "2-digit",
second: "2-digit",
hour12: false,
}).format(new Date());
}).formatToParts(new Date());
const get = function (type) {
const hit = parts.find(function (p) {
return p.type === type;
});
return hit ? hit.value : "";
};
return (
get("year") +
"-" +
get("month") +
"-" +
get("day") +
" " +
get("hour") +
":" +
get("minute") +
":" +
get("second")
);
} catch (e) {
const d = new Date();
const utc = d.getTime() + d.getTimezoneOffset() * 60000;
@@ -352,9 +371,9 @@
};
return (
bj.getFullYear() +
"/" +
"-" +
p(bj.getMonth() + 1) +
"/" +
"-" +
p(bj.getDate()) +
" " +
p(bj.getHours()) +
@@ -369,7 +388,9 @@
function tickBeijingClock() {
const el = document.getElementById("overview-bj-time");
if (!el) return;
el.textContent = formatBeijingNow();
const text = formatBeijingNow();
el.textContent = text;
el.setAttribute("datetime", text.replace(" ", "T") + "+08:00");
}
function boot() {