mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-11 22:49:39 +08:00
🐛 fix(export): 导出数据日期时间格式化为本地时区 yyyy-MM-dd HH:mm:ss
- formatExportCellText default 分支增加字符串日期时间解析与格式化 - normalizeExportJSONValue 新增 time.Time 和字符串日期时间处理 - 覆盖 CSV/JSON/XLSX/HTML/Markdown 全部导出格式 - refs #270
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user