修改了时间计算方法

This commit is contained in:
2024-08-08 17:00:57 +08:00
parent 3dce6ebfc8
commit 6137740b13
21 changed files with 119 additions and 593 deletions
+24
View File
@@ -0,0 +1,24 @@
package utils
import (
"hepa-calc-admin-api/api/model"
"time"
)
// StrToLocalTime 字符串时间转localtime
func StrToLocalTime(s string) (*model.LocalTime, error) {
// 获取本地时区
location, err := time.LoadLocation("Local")
if err != nil {
return nil, err
}
timeParse, err := time.ParseInLocation("2006-01-02 15:04:05", s, location)
if err != nil {
return nil, err
}
t := model.LocalTime(timeParse)
return &t, nil
}