fix: enforce Beijing Time (UTC+8) globally by replacing datetime.utcnow

This commit is contained in:
DXC
2026-03-20 15:23:20 +08:00
parent d7df1dea57
commit b08bbba718
3 changed files with 7 additions and 8 deletions

View File

@ -16,8 +16,8 @@ redis_client = None
def beijing_time():
"""获取北京时间 (UTC+8)"""
return datetime.now(timezone(timedelta(hours=8)))
"""获取北京时间 (UTC+8),剥离时区信息以兼容数据库 naive DateTime 字段"""
return datetime.now(timezone(timedelta(hours=8))).replace(tzinfo=None)
# 2. 定义初始化函数 (供工厂函数 create_app 调用)