共用匯入檔名日期解析
All checks were successful
CD Pipeline / deploy (push) Successful in 57s

This commit is contained in:
OoO
2026-05-13 09:58:56 +08:00
parent 1ca535720f
commit 317ff1bf02
3 changed files with 22 additions and 20 deletions

View File

@@ -4,6 +4,7 @@
"""
import hashlib
import re
from datetime import datetime
def slugify(text):
@@ -43,11 +44,8 @@ def extract_snapshot_date_from_filename(filename):
return None
date_str = match.group(1)
try:
year = date_str[:4]
month = date_str[4:6]
day = date_str[6:8]
return f"{year}-{month}-{day}"
except Exception:
return datetime.strptime(date_str, "%Y%m%d").date().isoformat()
except ValueError:
return None