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})