Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRoesler committed Feb 25, 2025
1 parent 36cd85f commit 69b4347
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions job.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ type defaultCron struct {
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
if strings.HasPrefix(crontab, "TZ=") || strings.HasPrefix(crontab, "CRON_TZ=") {
withLocation = crontab
Expand All @@ -161,7 +161,7 @@ func (r *defaultCron) IsValid(crontab string, location *time.Location, now time.
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)
cronSchedule, err = p.Parse(withLocation)
} else {
Expand All @@ -173,15 +173,15 @@ func (r *defaultCron) IsValid(crontab string, location *time.Location, now time.
if cronSchedule.Next(now).IsZero() {
return ErrCronJobInvalid
}
r.cronSchedule = cronSchedule
c.cronSchedule = cronSchedule
return nil
}

func (r *defaultCron) Next(lastRun time.Time) time.Time {
return r.cronSchedule.Next(lastRun)
func (c *defaultCron) Next(lastRun time.Time) time.Time {
return c.cronSchedule.Next(lastRun)
}

// default cron job implimentation
// default cron job implementation
var _ JobDefinition = (*cronJobDefinition)(nil)

type cronJobDefinition struct {
Expand All @@ -195,7 +195,7 @@ func (c cronJobDefinition) setup(j *internalJob, location *time.Location, now ti
}

if err := c.cron.IsValid(c.crontab, location, now); err != nil {
return err
return err
}

j.jobSchedule = &cronJob{crontab: c.crontab, cronSchedule: c.cron}
Expand Down

0 comments on commit 69b4347

Please sign in to comment.