diff --git a/crontab.go b/crontab.go index 7d7a424..e6d3946 100644 --- a/crontab.go +++ b/crontab.go @@ -185,12 +185,14 @@ func (cron *Crontab) FromString(crontab string) error { // "f1-2|5-10x5,f1|10m,10-15,f1" cron.lastStatus = true - cron.isCalculated = false + cron.isCalculated = true + cron.nextTime = time.Now() + cron.interval = clinked.NewCircularLinked() var intervalList []interface{} intervalList = parseIntervalString(matches[0]) cron.interval.Append(intervalList...) - cron.TimeUp() + case 5: cron.min = createTimePointer(matches[0], 0, 59, true) cron.hour = createTimePointer(matches[1], 0, 23, true) @@ -328,7 +330,7 @@ func (cron *Crontab) intervalCalculateNextTime(now time.Time) { func (cron *Crontab) intervalTimeUp() bool { - if cron.isCalculated != false { + if cron.isCalculated { // 需要调用nexttime()才能正常正常计算下次的时间 now := time.Now() if now.Unix() >= cron.nextTime.Unix() { cron.isCalculated = false