- append " 00:00:00" form pure date in Time2Str.

This commit is contained in:
gazebo
2018-09-30 18:52:40 +08:00
parent 521b3c9f25
commit eb7044d9e2

View File

@@ -215,6 +215,9 @@ func Time2Str(t time.Time) string {
func Str2Time(timeStr string) time.Time {
timeStr = strings.Replace(timeStr, "T", " ", 1)
if strings.Index(timeStr, " ") == -1 {
timeStr += " 00:00:00"
}
retVal, err := time.ParseInLocation("2006-01-02 15:04:05", timeStr, time.Local)
if err != nil {
baseapi.SugarLogger.Errorf("time.ParseInLocation failed, timeStr:%v, error:%v", timeStr, err)