This commit is contained in:
shoopea 2019-05-09 11:08:50 +08:00
parent 0139b9644d
commit 9b75c74660

7
def.go
View File

@ -4,6 +4,7 @@ import (
"errors"
"log"
"regexp"
"strconv"
"time"
)
@ -120,9 +121,9 @@ func fromChatWarsDate(d string) (t time.Time, err error) {
}
t, _ := time.Parse(time.RFC3339, "2018-01-31T00:00:00+00:00")
t = t.AddDate(0, 0, (days / 3))
t = t.Add((days % 3) * 8 * time.Hour)
t = t.Add(strconv.Atoi(r.ReplaceAllString(d, "${Hour}")) * 20 * time.Minute)
t = t.Add(strconv.Atoi(r.ReplaceAllString(d, "${Minute}")) * 20 * time.Second)
t = t.Add(time.Hour * ((days % 3) * 8))
t = t.Add(time.Minute * (strconv.Atoi(r.ReplaceAllString(d, "${Hour}")) * 20))
t = t.Add(time.Second * (strconv.Atoi(r.ReplaceAllString(d, "${Minute}")) * 20))
return t, nil
} else {
return time.Now(), errors.New("Wrong format")