修复部分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"
"math"
"strconv"
"strings"
"time"
)
@ -103,7 +104,22 @@ func ObjToTime(obj interface{}, e ...*Error) time.Time {
//字符串类型只支持标准mysql datetime格式
if tInt == 0 {
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 {
t, e := time.Parse("2006-01-02 15:04:05", tStr)
if e == nil {