From e7ddce06ea41834c57390ada247134eede4debbc Mon Sep 17 00:00:00 2001 From: ylhan Date: Tue, 22 Sep 2026 00:18:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=A1=B5=E9=9D=A2=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=88=B3=E7=BB=9F=E4=B8=80=E5=AD=98UTC(Z),=20=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E6=8C=89=E8=AE=BF=E9=97=AE=E8=80=85=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E6=97=B6=E5=8C=BA=E6=98=BE=E7=A4=BA,=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E5=AE=B9=E5=99=A8=E6=97=B6=E5=8C=BA=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?8=E5=B0=8F=E6=97=B6=E5=81=8F=E5=B7=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xinquan/app.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xinquan/app.py b/xinquan/app.py index 944d900..e3aac8f 100644 --- a/xinquan/app.py +++ b/xinquan/app.py @@ -204,7 +204,9 @@ const state={pages:[], mode:'list', current:null, content:''}; const umarked = typeof marked==='undefined'; function toast(msg){const t=$('#toast');t.textContent=msg;t.classList.add('show');clearTimeout(t._h);t._h=setTimeout(()=>t.classList.remove('show'),1800);} -function fmt(ts){ if(!ts)return ''; try{return new Date(ts).toLocaleString('zh-CN');}catch(e){return ts;} } +function fmt(ts){ if(!ts)return ''; const s=String(ts); + const iso=(/Z$/i.test(s)||/([+-]\d{2}:\d{2})$/.test(s))?s:s+'Z'; + try{return new Date(iso).toLocaleString('zh-CN');}catch(e){return ts;} } async function loadPages(){ state.pages = await api('/api/pages'); @@ -532,7 +534,7 @@ class Handler(BaseHTTPRequestHandler): with _lock: pages = _read_pages() pid = uuid.uuid4().hex[:12] - now = time.strftime("%Y-%m-%dT%H:%M:%S") + now = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()) pages[pid] = {"title": data["title"].strip(), "content": data.get("content", ""), "created": now, "updated": now} @@ -551,7 +553,7 @@ class Handler(BaseHTTPRequestHandler): pages[pid]["title"] = data["title"].strip() if "content" in data: pages[pid]["content"] = data["content"] or "" - pages[pid]["updated"] = time.strftime("%Y-%m-%dT%H:%M:%S") + pages[pid]["updated"] = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()) _write_pages(pages) self._json({"id": pid})