Documentation
¶
Overview ¶
Package parserext provides cron.Parser extensions beyond the standard grammar. NewQuartzParser adds the Quartz day tokens L, L-n, LW, nW, N#M and NL while forwarding everything else to the standard parser.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewQuartzParser ¶
NewQuartzParser returns a cron.Parser that handles standard specs plus the Quartz day tokens L, L-n, LW, nW, N#M and NL, in five- or six-field (leading seconds) form. Numeric day-of-week stays cron-style 0-6 Sunday-first, not Quartz's 1-7; name forms (FRI#3, FRIL) are unambiguous. Specs without Quartz-only tokens, descriptors and TZ prefixes are forwarded to the standard parser, so their errors and semantics are identical. A nil loc means time.Local. Install it with cron.WithParser.
Example ¶
package main
import (
"fmt"
"time"
"github.com/libtnb/cron"
"github.com/libtnb/cron/parserext"
)
func main() {
p := parserext.NewQuartzParser(time.UTC)
s, err := p.Parse("0 0 22 ? * 5L") // 22:00 on the last Friday of each month
if err != nil {
fmt.Println(err)
return
}
from := time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC)
for _, t := range cron.NextN(s, from, 2) {
fmt.Println(t.Format("Mon 2006-01-02 15:04"))
}
}
Output: Fri 2026-01-30 22:00 Fri 2026-02-27 22:00
Types ¶
type QuartzSchedule ¶
type QuartzSchedule struct {
// contains filtered or unexported fields
}
QuartzSchedule is a compiled expression containing Quartz day tokens, as produced by NewQuartzParser. It is immutable and safe for concurrent use; the zero value never fires.
func (*QuartzSchedule) Location ¶
func (s *QuartzSchedule) Location() *time.Location
Location returns the schedule's evaluation time zone; cron.AnalyzeSpecWith reports it.
func (*QuartzSchedule) Next ¶
func (s *QuartzSchedule) Next(t time.Time) time.Time
Next returns the first firing strictly after t, evaluated in the schedule's Location and returned in t's location, or zero when nothing matches within the next five years. It shares cron.SpecSchedule.Next's structure: bitmask jumps with wall-clock reconstruction for the hour, so DST spring-forward days are handled correctly.