File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -348,6 +348,14 @@ func ExampleMonthlyJob() {
348348 )
349349}
350350
351+ func ExampleNewDefaultCron () {
352+ c := gocron .NewDefaultCron (true )
353+ err := c .IsValid ("* * * * * *" , time .Local , time .Now ())
354+ if err != nil {
355+ panic (err )
356+ }
357+ }
358+
351359func ExampleNewScheduler () {
352360 s , _ := gocron .NewScheduler ()
353361 defer func () { _ = s .Shutdown () }()
Original file line number Diff line number Diff line change @@ -140,6 +140,15 @@ func newDefaultCronImplementation(withSeconds bool) Cron {
140140 }
141141}
142142
143+ // NewDefaultCron returns the default cron implementation for use outside the
144+ // scheduling of a job. For example, validating crontab syntax before passing to the
145+ // NewJob function.
146+ func NewDefaultCron (cronStatementsIncludeSeconds bool ) Cron {
147+ return & defaultCron {
148+ withSeconds : cronStatementsIncludeSeconds ,
149+ }
150+ }
151+
143152var _ Cron = (* defaultCron )(nil )
144153
145154type defaultCron struct {
You can’t perform that action at this time.
0 commit comments