mirror of
https://gitlab.52pay.top/go/easygoadmin.git
synced 2025-09-27 01:38:05 +08:00
fix: date组件兼容time格式
date组件兼容time格式
This commit is contained in:
@@ -9,6 +9,7 @@ package widget
|
||||
import (
|
||||
"gitlab.52pay.top/go/easygoadmin/utils/gconv"
|
||||
"html/template"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -47,8 +48,21 @@ func Date(param string, value interface{}) template.HTML {
|
||||
if dateType == "date" {
|
||||
dateFormat = "2006-01-02"
|
||||
}
|
||||
|
||||
if value != nil {
|
||||
dateValue = time.Unix(gconv.Int64(value), 0).Format(dateFormat)
|
||||
switch value.(type) {
|
||||
case string:
|
||||
if dt, err := time.Parse(dateFormat, value.(string)); err == nil {
|
||||
dateValue = dt.Format(dateFormat)
|
||||
break
|
||||
}
|
||||
if unix, err := strconv.Atoi(value.(string)); err == nil {
|
||||
dateValue = time.Unix(int64(unix), 0).Format(dateFormat)
|
||||
break
|
||||
}
|
||||
case int, int64, int32:
|
||||
dateValue = time.Unix(gconv.Int64(value), 0).Format(dateFormat)
|
||||
}
|
||||
}
|
||||
|
||||
html := `<input name="` + dateName + `" id="` + dateName + `" value="` + dateValue + `" lay-verify="` + dateType + `" placeholder="请选择` + dateTips + `" autocomplete="off" class="layui-input date-icon" type="text">
|
||||
|
Reference in New Issue
Block a user