Documentation
¶
Overview ¶
Package cronexpr parses cron time expressions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Expression ¶
type Expression struct {
// contains filtered or unexported fields
}
A Expression represents a specific cron time expression as defined at <https://github.com/gorhill/cronexpr#implementation>
func MustParse ¶
func MustParse(cronLine string) *Expression
MustParse returns a new Expression pointer. It expects a well-formed cron expression. If a malformed cron expression is supplied, it will `panic`. See <https://github.com/gorhill/cronexpr#implementation> for documentation about what is a well-formed cron expression from this library's point of view.
func Parse ¶
func Parse(cronLine string) (*Expression, error)
Parse returns a new Expression pointer. An error is returned if a malformed cron expression is supplied. See <https://github.com/gorhill/cronexpr#implementation> for documentation about what is a well-formed cron expression from this library's point of view.
func (*Expression) Last ¶
func (expr *Expression) Last(fromTime time.Time) time.Time
Last returns the closest time instant immediately before `fromTime` which matches the cron expression `expr`.
The `time.Location` of the returned time instant is the same as that of `fromTime`.
The zero value of time.Time is returned if no matching time instant exists or if a `fromTime` is itself a zero value.
func (*Expression) Next ¶
func (expr *Expression) Next(fromTime time.Time) time.Time
Next returns the closest time instant immediately following `fromTime` which matches the cron expression `expr`.
The `time.Location` of the returned time instant is the same as that of `fromTime`.
The zero value of time.Time is returned if no matching time instant exists or if a `fromTime` is itself a zero value.
func (*Expression) NextN ¶
NextN returns a slice of `n` closest time instants immediately following `fromTime` which match the cron expression `expr`.
The time instants in the returned slice are in chronological ascending order. The `time.Location` of the returned time instants is the same as that of `fromTime`.
A slice with len between [0-`n`] is returned, that is, if not enough existing matching time instants exist, the number of returned entries will be less than `n`.