From 1140087c45dd4990d7ffa3cad8bb3b02bb076eb7 Mon Sep 17 00:00:00 2001 From: eson <474420502@qq.com> Date: Fri, 21 Dec 2018 23:30:21 +0800 Subject: [PATCH] fix first Call NextTime --- crontab.go | 4 ++-- crontab_test.go | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crontab.go b/crontab.go index 1fe63c6..5150c9d 100644 --- a/crontab.go +++ b/crontab.go @@ -146,7 +146,7 @@ func (cron *Crontab) FromString(crontab string) error { var intervalList []interface{} intervalList = parseIntervalString(matches[0]) cron.interval.Append(intervalList...) - cron.TimeUp() + cron.NextTime() case 5: cron.min = createTimePointer(matches[0], 0, 59, true) cron.hour = createTimePointer(matches[1], 0, 23, true) @@ -155,7 +155,7 @@ func (cron *Crontab) FromString(crontab string) error { cron.week = createTimePointer(matches[4], 0, 6, true) cron.createYearPlan() - cron.TimeUp() + cron.NextTime() default: return errors.New("mathches len != want, check crontab string") } diff --git a/crontab_test.go b/crontab_test.go index 190d1d7..97f9586 100644 --- a/crontab_test.go +++ b/crontab_test.go @@ -66,6 +66,10 @@ func isInRangeTime(sec, t float64) error { return fmt.Errorf("计算错误 范围 %f-%f interval time is %f", t-0.05, t+0.05, sec) } +func TestParseIntervalOnline1(t *testing.T) { + +} + func TestParseIntervalPlus(t *testing.T) { // crontab := "0-5/2,7-30/3,30,35,40-^1 * * * *" //(秒) 分 时 号(每月的多少号, 要注意月可可能性) 星期几(每个星期的) /每 ,列表 -范围 // crondata := NewCrontab("*22 * * * *")