option.go 604 B

123456789101112131415161718192021222324252627282930
  1. package cron
  2. import (
  3. "log"
  4. "time"
  5. )
  6. // Option represents a modification to the default behavior of a Cron.
  7. type Option func(*Cron)
  8. // WithLocation overrides the timezone of the cron instance.
  9. func WithLocation(loc *time.Location) Option {
  10. return func(c *Cron) {
  11. c.location = loc
  12. }
  13. }
  14. // WithParser overrides the parser used for interpreting job schedules.
  15. func WithParser(p Parser) Option {
  16. return func(c *Cron) {
  17. c.parser = p
  18. }
  19. }
  20. // WithPanicLogger overrides the logger used for logging job panics.
  21. func WithPanicLogger(l *log.Logger) Option {
  22. return func(c *Cron) {
  23. c.logger = l
  24. }
  25. }