* feat:perfect

* fix:buffer time

* fix:zap freifx
This commit is contained in:
Bin
2022-10-06 21:48:19 +08:00
committed by GitHub
parent 1cbbce741a
commit ba7a16250b
4 changed files with 61 additions and 6 deletions

View File

@@ -7,15 +7,21 @@ import (
)
func ParseDuration(d string) (time.Duration, error) {
d = strings.TrimSpace(d)
dr, err := time.ParseDuration(d)
if err == nil {
return dr, nil
}
if strings.HasSuffix(d, "d") {
h := strings.TrimSuffix(d, "d")
hour, _ := strconv.Atoi(h)
if strings.Contains(d, "d") {
index := strings.Index(d, "d")
hour, _ := strconv.Atoi(d[:index])
dr = time.Hour * 24 * time.Duration(hour)
return dr, nil
ndr, err := time.ParseDuration(d[index+1:])
if err != nil {
return dr, nil
}
return dr + ndr, nil
}
dv, err := strconv.ParseInt(d, 10, 64)