Documentation ¶
Overview ¶
Package cron provides methods for working with cron expressions
Index ¶
Examples ¶
Constants ¶
View Source
const ( YEARLY = "0 0 1 1 *" ANNUALLY = "0 0 1 1 *" MONTHLY = "0 0 1 * *" WEEKLY = "0 0 * * 0" DAILY = "0 0 * * *" HOURLY = "0 * * * *" )
Aliases
Variables ¶
View Source
var ( // ErrMalformedExpression is returned by the Parse method if given cron expression has // wrong or unsupported format ErrMalformedExpression = errors.New("Expression must have 5 tokens") // ErrZeroInterval is returned if interval part of expression is empty ErrZeroInterval = errors.New("Interval can't be less or equals 0") )
Functions ¶
This section is empty.
Types ¶
type Expr ¶
type Expr struct {
// contains filtered or unexported fields
}
Expr cron expression struct
func Parse ¶
Parse parse cron expression https://en.wikipedia.org/wiki/Cron
Example ¶
expr, err := Parse("0,15,30,45 0,6,12,18 1-10,15,31 * Mon-Fri") if err != nil { return } m1 := time.Date(2020, 1, 1, 18, 15, 0, 0, time.Local) m2 := time.Date(2020, 1, 1, 18, 20, 0, 0, time.Local) fmt.Printf("Execute1: %t\n", expr.IsDue(m1)) fmt.Printf("Execute2: %t\n", expr.IsDue(m2))
Output: Execute1: true Execute2: false
func (*Expr) Next ¶
Next get time of next matched moment
Example ¶
expr, err := Parse("0,15,30,45 0,6,12,18 1-10,15,31 * Mon-Fri") if err != nil { return } m := time.Date(2020, 1, 1, 18, 15, 0, 0, time.UTC) fmt.Printf("%v\n", expr.Next(m))
Output: 2020-01-01 18:30:00 +0000 UTC
Click to show internal directories.
Click to hide internal directories.