This commit is contained in:
shoopea 2019-05-09 11:12:17 +08:00
parent 9b75c74660
commit 1956077d86

6
def.go
View File

@ -119,11 +119,13 @@ func fromChatWarsDate(d string) (t time.Time, err error) {
for i := 1; i < strconv.Atoi(r.ReplaceAllString(d, "${Day}")); i++ { for i := 1; i < strconv.Atoi(r.ReplaceAllString(d, "${Day}")); i++ {
days++ days++
} }
hour, _ := strconv.Atoi(r.ReplaceAllString(d, "${Hour}"))
minute, _ := strconv.Atoi(r.ReplaceAllString(d, "${Minute}"))
t, _ := time.Parse(time.RFC3339, "2018-01-31T00:00:00+00:00") t, _ := time.Parse(time.RFC3339, "2018-01-31T00:00:00+00:00")
t = t.AddDate(0, 0, (days / 3)) t = t.AddDate(0, 0, (days / 3))
t = t.Add(time.Hour * ((days % 3) * 8)) t = t.Add(time.Hour * ((days % 3) * 8))
t = t.Add(time.Minute * (strconv.Atoi(r.ReplaceAllString(d, "${Hour}")) * 20)) t = t.Add(time.Minute * (hour * 20))
t = t.Add(time.Second * (strconv.Atoi(r.ReplaceAllString(d, "${Minute}")) * 20)) t = t.Add(time.Second * (minute * 20))
return t, nil return t, nil
} else { } else {
return time.Now(), errors.New("Wrong format") return time.Now(), errors.New("Wrong format")