mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-12 07:10:44 +08:00
Some checks failed
Docker Publish / build-and-push (push) Has been cancelled
* fix: 修复资源时间格式解析错误导致搜索失败的问题 * feat: 资源搜索结果显示来源通道
16 lines
539 B
Python
16 lines
539 B
Python
from datetime import datetime, timezone, timedelta
|
|
|
|
|
|
def iso_to_cst(iso_time_str: str) -> str:
|
|
"""将 ISO 格式的时间字符串转换为 CST(China Standard Time) 时间并格式化为 %Y-%m-%d %H:%M:%S 格式
|
|
|
|
Args:
|
|
iso_time_str (str): ISO 格式时间字符串
|
|
|
|
Returns:
|
|
str: CST(China Standard Time) 时间字符串
|
|
"""
|
|
dt = datetime.fromisoformat(iso_time_str)
|
|
dt_cst = dt.astimezone(timezone(timedelta(hours=8)))
|
|
return dt_cst.strftime("%Y-%m-%d %H:%M:%S") if dt_cst.year >= 1970 else ""
|