From 7d543e06c60aa1dc5fce49dd0746e938b0d4ec05 Mon Sep 17 00:00:00 2001 From: Syngnat Date: Fri, 20 Mar 2026 15:44:53 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(export):=20=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E6=95=B0=E6=8D=AE=E6=97=A5=E6=9C=9F=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=B8=BA=E6=9C=AC=E5=9C=B0=E6=97=B6?= =?UTF-8?q?=E5=8C=BA=20yyyy-MM-dd=20HH:mm:ss?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - formatExportCellText default 分支增加字符串日期时间解析与格式化 - normalizeExportJSONValue 新增 time.Time 和字符串日期时间处理 - 覆盖 CSV/JSON/XLSX/HTML/Markdown 全部导出格式 - refs #270 --- internal/app/methods_file.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/internal/app/methods_file.go b/internal/app/methods_file.go index e484091..3d02edf 100644 --- a/internal/app/methods_file.go +++ b/internal/app/methods_file.go @@ -2207,7 +2207,12 @@ func formatExportCellText(val interface{}) string { } return text default: - return fmt.Sprintf("%v", val) + text := fmt.Sprintf("%v", val) + // 字符串型日期时间值(如 RFC3339 "2026-03-10T17:01:55+08:00")格式化为本地时区 yyyy-MM-dd HH:mm:ss + if parsed, ok := parseTemporalString(text); ok { + return parsed.Local().Format("2006-01-02 15:04:05") + } + return text } } @@ -2217,6 +2222,18 @@ func normalizeExportJSONValue(val interface{}) interface{} { } switch v := val.(type) { + case time.Time: + return v.Local().Format("2006-01-02 15:04:05") + case *time.Time: + if v == nil { + return nil + } + return v.Local().Format("2006-01-02 15:04:05") + case string: + if parsed, ok := parseTemporalString(v); ok { + return parsed.Local().Format("2006-01-02 15:04:05") + } + return v case float32: f := float64(v) if math.IsNaN(f) || math.IsInf(f, 0) {