diff --git a/crontab.go b/crontab.go index 923584a..842b6cf 100644 --- a/crontab.go +++ b/crontab.go @@ -109,16 +109,16 @@ func (cron *Crontab) TimeUp() bool { } // NextTime 返回下次任务的时间 -func (cron *Crontab) NextTime() *time.Time { +func (cron *Crontab) NextTime() time.Time { if cron.interval != nil { - return &cron.nextTime + return cron.nextTime } if len(cron.WillPlans) > 0 { - return &cron.WillPlans[0] + return cron.WillPlans[0] } - return nil + return time.Now().Add(time.Second * 2) } func (cron *Crontab) String() string { diff --git a/crontab_test.go b/crontab_test.go index 77663ab..3a126ed 100644 --- a/crontab_test.go +++ b/crontab_test.go @@ -26,8 +26,8 @@ func TestParseCrontab(t *testing.T) { } cron.createYearPlan() - if !cron.TimeUp() { - t.Error("timeup error") + if cron.TimeUp() { + t.Error("timeup error", cron.WillPlans[0:2]) } PrintMemUsage()