feat(schedule): 新增调度时区转换功能

This commit is contained in:
hugo committed 2026-06-10 11:29:41 +08:00
1 parent 6d40d504c5
commit a88b60e505
2 files changed
+157 -9

No files matched your search

+9
View File
@@ -19,6 +19,15 @@ def utc_iso_now() -> str:
return datetime.now(timezone.utc).replace(microsecond=0).isoformat().replace("+00:00", "Z")
def utc_iso(dt: datetime | None) -> str | None:
"""将 naive UTC datetime 序列化为带 Z 后缀的 ISO 字符串,便于前端正确转本地时区。"""
if dt is None:
return None
if dt.tzinfo is not None:
return dt.astimezone(timezone.utc).replace(tzinfo=None).isoformat() + "Z"
return dt.isoformat() + "Z"
def ok(data: Any, *, request_id: str | None = None, status: int = 200):
payload: dict[str, Any] = {
"success": True,