调整正确的统计让第一次直接执行
This commit is contained in:
parent
7342ef6605
commit
0f83cb5e66
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user