修复部分bug

This commit is contained in:
hoteas 2022-11-08 16:05:47 +08:00
parent a298cb3d52
commit 56f66fcaed

View File

@ -5,6 +5,7 @@ import (
"errors" "errors"
"math" "math"
"strconv" "strconv"
"strings"
"time" "time"
) )
@ -103,7 +104,22 @@ func ObjToTime(obj interface{}, e ...*Error) time.Time {
//字符串类型只支持标准mysql datetime格式 //字符串类型只支持标准mysql datetime格式
if tInt == 0 { if tInt == 0 {
tStr := ObjToStr(obj) tStr := ObjToStr(obj)
timeNewStr := ""
timeNewStrs := strings.Split(tStr, "-")
for _, v := range timeNewStrs {
if v == "" {
continue
}
if len(v) == 1 {
v = "0" + v
}
if timeNewStr == "" {
timeNewStr = v
continue
}
timeNewStr = timeNewStr + "-" + v
}
tStr = timeNewStr
if len(tStr) > 18 { if len(tStr) > 18 {
t, e := time.Parse("2006-01-02 15:04:05", tStr) t, e := time.Parse("2006-01-02 15:04:05", tStr)
if e == nil { if e == nil {