From 77c6722a92a2480a80f018e4397aa7497ccaf60b Mon Sep 17 00:00:00 2001 From: v6ole Date: Tue, 12 May 2026 10:21:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=B9=BF=E8=A5=BF?= =?UTF-8?q?=E6=94=BF=E9=87=87=E7=BD=91=E5=85=AC=E5=91=8A=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=97=B6=E5=8C=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fromtimestamp() 在 UTC 服务器上会少 8 小时,改为明确指定 Asia/Shanghai 时区解析。 Co-Authored-By: Claude Sonnet 4.6 --- app/crawler/parsers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/crawler/parsers.py b/app/crawler/parsers.py index 4f1689c..2d92fd0 100644 --- a/app/crawler/parsers.py +++ b/app/crawler/parsers.py @@ -2,6 +2,9 @@ import hashlib from datetime import datetime from typing import Any from urllib.parse import urljoin +from zoneinfo import ZoneInfo + +_TZ = ZoneInfo("Asia/Shanghai") from bs4 import BeautifulSoup @@ -30,7 +33,7 @@ def parse_gxgp_api_response( if not timestamp: continue try: - publish_date = datetime.fromtimestamp(int(timestamp) / 1000) + publish_date = datetime.fromtimestamp(int(timestamp) / 1000, tz=_TZ).replace(tzinfo=None) except (ValueError, TypeError): continue