From 316d6164192644c40d9a26dd54a3019e6826f2a8 Mon Sep 17 00:00:00 2001 From: eson <474420502@qq.com> Date: Fri, 7 Dec 2018 04:42:53 +0800 Subject: [PATCH] fix --- crontab.go | 8 ++++---- crontab_test.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) 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()