test
This commit is contained in:
parent
515886eaba
commit
a80127fdc5
22
def.go
22
def.go
@ -104,8 +104,26 @@ func fromChatWarsDate(d string) (t time.Time, err error) {
|
||||
log.Printf("fromChatWarsDate : Year : %s\n", r.ReplaceAllString(d, "${Year}"))
|
||||
log.Printf("fromChatWarsDate : Hour : %s\n", r.ReplaceAllString(d, "${Hour}"))
|
||||
log.Printf("fromChatWarsDate : Minute : %s\n", r.ReplaceAllString(d, "${Minute}"))
|
||||
|
||||
return time.Now(), nil
|
||||
days := int(0)
|
||||
for i := 1059; i < strconv.Atoi(r.ReplaceAllString(d, "${Year}")); i++ {
|
||||
days = days + 365
|
||||
}
|
||||
for i := 1; i < chatWarsMonth[r.ReplaceAllString(d, "${Month}")]; i++ {
|
||||
if _, special := chatWarsDaysSpecial[strconv.Atoi(r.ReplaceAllString(d, "${Year}"))][i]; special {
|
||||
days = days + chatWarsDaysSpecial[strconv.Atoi(r.ReplaceAllString(d, "${Year}"))][i]
|
||||
} else {
|
||||
days = days + chatWarsDays[i]
|
||||
}
|
||||
}
|
||||
for i := 1; i < strconv.Atoi(r.ReplaceAllString(d, "${Day}")); i++ {
|
||||
days++
|
||||
}
|
||||
t, _ := time.Parse(time.RFC3339, "2018-01-31T00:00:00+00:00")
|
||||
t = t.Add((days / 3) * time.Day())
|
||||
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())
|
||||
return t, nil
|
||||
} else {
|
||||
return time.Now(), errors.New("Wrong format")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user