This commit is contained in:
aozhiwei 2024-06-21 16:49:38 +08:00
parent de3dc89691
commit 9afe1aa679

View File

@ -270,6 +270,31 @@ func CalcCrc32(data string) uint32 {
return c.Sum32()
}
func SmartParseTimeToMills(timeStr string) int64 {
if IsPureNumber(timeStr) {
return ToInt64(timeStr) * 1000
}
if StrContains(timeStr, "T") {
t, err := time.Parse(time.RFC3339, timeStr)
if err == nil {
return t.UnixNano() / int64(time.Millisecond)
}
} else if StrContains(timeStr, ".") {
const layout = "2006-01-02 15:04:05.000"
t, err := time.Parse(layout, timeStr)
if err == nil {
return t.UnixNano() / int64(time.Millisecond)
}
} else {
const layout = "2006-01-02 15:04:05"
t, err := time.Parse(layout, timeStr)
if err == nil {
return t.UnixNano() / int64(time.Millisecond)
}
}
return 0
}
func GetSyncMapSize(m sync.Map) int {
var size int
m.Range(func(key, value interface{}) bool {