fix cronjob msg parse

Signed-off-by: soulseen <sunzhu@yunify.com>
This commit is contained in:
soulseen
2019-09-18 14:57:15 +08:00
parent c53bdcad60
commit 31eacd6c29
2 changed files with 15 additions and 7 deletions

View File

@@ -779,18 +779,22 @@ func parseCronJobTime(msg string) (string, string, error) {
times := strings.Split(msg, ";")
lastTmp := strings.SplitN(times[0], " ", 2)
lastTime := strings.SplitN(lastTmp[1], " UTC", 2)
lastUinx, err := time.Parse(cronJobLayout, lastTime[0])
lastTmp := strings.Split(times[0], " ")
lastCount := len(lastTmp)
lastTmp = lastTmp[lastCount-7 : lastCount-1]
lastTime := strings.Join(lastTmp, " ")
lastUinx, err := time.Parse(cronJobLayout, lastTime)
if err != nil {
klog.Error(err)
return "", "", err
}
last := lastUinx.Format(time.RFC3339)
nextTmp := strings.SplitN(times[1], " ", 3)
nextTime := strings.SplitN(nextTmp[2], " UTC", 2)
nextUinx, err := time.Parse(cronJobLayout, nextTime[0])
nextTmp := strings.Split(times[1], " ")
nextCount := len(nextTmp)
nextTmp = nextTmp[nextCount-7 : nextCount-1]
nextTime := strings.Join(nextTmp, " ")
nextUinx, err := time.Parse(cronJobLayout, nextTime)
if err != nil {
klog.Error(err)
return "", "", err