fix first Call NextTime

This commit is contained in:
eson 2018-12-21 23:30:21 +08:00
parent 2904c8f38c
commit 1140087c45
2 changed files with 6 additions and 2 deletions

View File

@ -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")
}

View File

@ -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 * * * *")