mirror of
https://github.com/LibraHp/GetQzonehistory.git
synced 2024-12-29 07:29:40 +00:00
修复转换为html时日期格式不正确导致转换失败的问题
This commit is contained in:
parent
1a2cedc200
commit
822e4b2f66
11
main.py
11
main.py
@ -23,6 +23,15 @@ def signal_handler(signal, frame):
|
|||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
def safe_strptime(date_str):
|
||||||
|
try:
|
||||||
|
# 尝试按照指定格式解析日期
|
||||||
|
return datetime.strptime(date_str, "%Y年%m月%d日 %H:%M")
|
||||||
|
except ValueError:
|
||||||
|
# 如果日期格式不对,返回 None
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
# 还原QQ空间网页版说说
|
# 还原QQ空间网页版说说
|
||||||
def render_html(shuoshuo_path, zhuanfa_path):
|
def render_html(shuoshuo_path, zhuanfa_path):
|
||||||
# 读取 Excel 文件内容
|
# 读取 Excel 文件内容
|
||||||
@ -37,7 +46,7 @@ def render_html(shuoshuo_path, zhuanfa_path):
|
|||||||
# 合并所有数据
|
# 合并所有数据
|
||||||
all_data = shuoshuo_data + zhuanfa_data
|
all_data = shuoshuo_data + zhuanfa_data
|
||||||
# 按时间排序
|
# 按时间排序
|
||||||
all_data.sort(key=lambda x: datetime.strptime(x[0], "%Y年%m月%d日 %H:%M"), reverse=True)
|
all_data.sort(key=lambda x: safe_strptime(x[0]) or datetime.min, reverse=True)
|
||||||
html_template, post_template = Tools.get_html_template()
|
html_template, post_template = Tools.get_html_template()
|
||||||
# 构建动态内容
|
# 构建动态内容
|
||||||
post_html = ""
|
post_html = ""
|
||||||
|
Loading…
Reference in New Issue
Block a user