修复复盘

This commit is contained in:
dekun
2026-05-21 20:12:25 +08:00
parent 1c449e2d97
commit f7dce1a004
6 changed files with 288 additions and 238 deletions
+22
View File
@@ -75,6 +75,28 @@ def utc_window_to_bj_sql_strings(start_utc, end_utc, app_tz):
return start_bj, end_bj
def normalize_bj_datetime_storage(raw):
"""表单 datetime-local(含 T)入库前统一为 YYYY-MM-DD HH:MM:SS(北京时间)。"""
s = (raw or "").strip().replace("T", " ").replace("Z", "").strip()
if not s:
return ""
for fmt, n in (("%Y-%m-%d %H:%M:%S", 19), ("%Y-%m-%d %H:%M", 16), ("%Y-%m-%d", 10)):
try:
return datetime.strptime(s[:n], fmt).strftime("%Y-%m-%d %H:%M:%S")
except ValueError:
continue
return s
def sql_list_time_field(*columns):
"""
SQLite 列表时间窗比较表达式。
journal_entries 的 open/close 可能含 'T',直接与 bounds(空格格式)比会误判为超出上界。
"""
cols = ", ".join(columns)
return f"REPLACE(COALESCE({cols}), 'T', ' ')"
SESSION_KEY_LIST_WIN = "list_win_filter"