crontab v1.0.0

This commit is contained in:
huangsimin 2018-12-06 10:17:10 +08:00
parent 46e451cc42
commit 3f3bfb2a97

View File

@ -91,6 +91,19 @@ func (cron *Crontab) TimeUp() bool {
return cron.linuxTimeUp()
}
// NextTime 返回下次任务的时间
func (cron *Crontab) NextTime() *time.Time {
if cron.interval != nil {
return &cron.nextTime
}
if len(cron.WillPlans) > 0 {
return &cron.WillPlans[0]
}
return nil
}
func (cron *Crontab) String() string {
return fmt.Sprintf("min:%s\nhour:%s\nday:%s\nmonth:%s\nweek:%s\n", spew.Sdump(cron.min), spew.Sdump(cron.hour), spew.Sdump(cron.day), spew.Sdump(cron.month), spew.Sdump(cron.week))
}
@ -173,7 +186,8 @@ func (cron *Crontab) linuxTimeUp() bool {
return istimeup
}
}
cron.SkipPlans = cron.WillPlans
cron.SkipPlans = append(cron.SkipPlans, cron.WillPlans...)
cron.WillPlans = nil
return istimeup
}