mirror of https://github.com/go-co-op/gocron.git
clean up
This commit is contained in:
parent
36cd85fc61
commit
69b4347c4c
12
job.go
12
job.go
|
|
@ -146,7 +146,7 @@ type defaultCron struct {
|
||||||
withSeconds bool
|
withSeconds bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *defaultCron) IsValid(crontab string, location *time.Location, now time.Time) error {
|
func (c *defaultCron) IsValid(crontab string, location *time.Location, now time.Time) error {
|
||||||
var withLocation string
|
var withLocation string
|
||||||
if strings.HasPrefix(crontab, "TZ=") || strings.HasPrefix(crontab, "CRON_TZ=") {
|
if strings.HasPrefix(crontab, "TZ=") || strings.HasPrefix(crontab, "CRON_TZ=") {
|
||||||
withLocation = crontab
|
withLocation = crontab
|
||||||
|
|
@ -161,7 +161,7 @@ func (r *defaultCron) IsValid(crontab string, location *time.Location, now time.
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
if r.withSeconds {
|
if c.withSeconds {
|
||||||
p := cron.NewParser(cron.SecondOptional | cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow | cron.Descriptor)
|
p := cron.NewParser(cron.SecondOptional | cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow | cron.Descriptor)
|
||||||
cronSchedule, err = p.Parse(withLocation)
|
cronSchedule, err = p.Parse(withLocation)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -173,15 +173,15 @@ func (r *defaultCron) IsValid(crontab string, location *time.Location, now time.
|
||||||
if cronSchedule.Next(now).IsZero() {
|
if cronSchedule.Next(now).IsZero() {
|
||||||
return ErrCronJobInvalid
|
return ErrCronJobInvalid
|
||||||
}
|
}
|
||||||
r.cronSchedule = cronSchedule
|
c.cronSchedule = cronSchedule
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *defaultCron) Next(lastRun time.Time) time.Time {
|
func (c *defaultCron) Next(lastRun time.Time) time.Time {
|
||||||
return r.cronSchedule.Next(lastRun)
|
return c.cronSchedule.Next(lastRun)
|
||||||
}
|
}
|
||||||
|
|
||||||
// default cron job implimentation
|
// default cron job implementation
|
||||||
var _ JobDefinition = (*cronJobDefinition)(nil)
|
var _ JobDefinition = (*cronJobDefinition)(nil)
|
||||||
|
|
||||||
type cronJobDefinition struct {
|
type cronJobDefinition struct {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue