fix(session): 所有时间显示改用本地时区而非 UTC
- /info 和 /sessions 中的时间戳通过 DateTime::from_timestamp_millis 后 调用 with_timezone(&Local) 转换为本地时间 - dump_to_file 和 dump_as_markdown 导出的时间也改用本地时区
This commit is contained in:
parent
fe4088cd1f
commit
24d3407b05
@ -431,7 +431,7 @@ impl Session {
|
||||
|
||||
let timestamp = if msg.timestamp > 0 {
|
||||
DateTime::from_timestamp_millis(msg.timestamp)
|
||||
.map(|dt| dt.format("%Y-%m-%d %H:%M:%S").to_string())
|
||||
.map(|dt| dt.with_timezone(&Local).format("%Y-%m-%d %H:%M:%S").to_string())
|
||||
.unwrap_or_default()
|
||||
} else {
|
||||
String::new()
|
||||
@ -503,7 +503,7 @@ impl Session {
|
||||
|
||||
let timestamp = if msg.timestamp > 0 {
|
||||
DateTime::from_timestamp_millis(msg.timestamp)
|
||||
.map(|dt| dt.format("%Y-%m-%d %H:%M:%S").to_string())
|
||||
.map(|dt| dt.with_timezone(&Local).format("%Y-%m-%d %H:%M:%S").to_string())
|
||||
.unwrap_or_default()
|
||||
} else {
|
||||
String::new()
|
||||
@ -774,10 +774,10 @@ impl SessionManager {
|
||||
let title = &session_guard.title;
|
||||
let model_name = &session_guard.provider_config.name;
|
||||
let created_at = chrono::DateTime::from_timestamp_millis(session_guard.created_at)
|
||||
.map(|dt| dt.format("%Y-%m-%d %H:%M:%S").to_string())
|
||||
.map(|dt| dt.with_timezone(&chrono::Local).format("%Y-%m-%d %H:%M:%S").to_string())
|
||||
.unwrap_or_default();
|
||||
let last_active_at = chrono::DateTime::from_timestamp_millis(session_guard.last_active_at)
|
||||
.map(|dt| dt.format("%Y-%m-%d %H:%M:%S").to_string())
|
||||
.map(|dt| dt.with_timezone(&chrono::Local).format("%Y-%m-%d %H:%M:%S").to_string())
|
||||
.unwrap_or_default();
|
||||
Ok((None, format!(
|
||||
"对话标题: {}\nSession ID: {}\n模型: {}\n用户消息: {} / 总消息: {}\n创建时间: {}\n最后活跃: {}",
|
||||
@ -814,7 +814,7 @@ impl SessionManager {
|
||||
} else {
|
||||
""
|
||||
};
|
||||
format!("- {} ({}){} — {}", d.session_id.dialog_id, d.title, current, chrono::DateTime::from_timestamp_millis(d.last_active_at).map(|dt| dt.format("%m-%d %H:%M").to_string()).unwrap_or_default())
|
||||
format!("- {} ({}){} — {}", d.session_id.dialog_id, d.title, current, chrono::DateTime::from_timestamp_millis(d.last_active_at).map(|dt| dt.with_timezone(&chrono::Local).format("%m-%d %H:%M").to_string()).unwrap_or_default())
|
||||
}).collect();
|
||||
Ok((None, format!("最近对话:\n{}", lines.join("\n"))))
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user