Documentation ¶
Index ¶
- Variables
- type Expression
- func (e Expression) MarshalText() (text []byte, err error)
- func (e Expression) Next(d time.Time) (n time.Time, ok bool)
- func (e *Expression) Scan(src interface{}) (err error)
- func (e Expression) String() string
- func (e *Expression) UnmarshalText(raw []byte) (err error)
- func (e Expression) Value() (val driver.Value, err error)
- type Schedule
Constants ¶
This section is empty.
Variables ¶
var ( MaxYears = 2199 MinYears = 1970 )
Non unit-related boundaries.
Functions ¶
This section is empty.
Types ¶
type Expression ¶
type Expression struct {
// contains filtered or unexported fields
}
An Expression is the Go representation of a Calendar Event as per Systemd's specification (with some exceptions, see the Parse method).
func MustParse ¶
func MustParse(raw string) (e Expression)
MustParse is like Parse but will panic in case of error.
func Parse ¶
func Parse(raw string) (exp Expression, err error)
Parse a raw string into an expression. Follows Systemd's Calendar Events specification with some exceptions: - Any timezone can be specified, not only UTC and local - Sub-second aren't handled - The end-of-month token isn't handled
Original implementation can be found here: https://github.com/systemd/systemd/blob/master/src/basic/calendarspec.c#L879
func (Expression) MarshalText ¶
func (e Expression) MarshalText() (text []byte, err error)
MarshalText implement the encoding.TextMarshaler interface.
func (Expression) Next ¶
Next returns the next point in time that will satisfy the schedule that is strictly after d.
Original implementation can be found here: https://github.com/systemd/systemd/blob/master/src/basic/calendarspec.c#L1199
func (*Expression) Scan ¶
func (e *Expression) Scan(src interface{}) (err error)
Scan implements the sql.Scanner interface, which allow to use an Expression as a database field and scan it.
func (Expression) String ¶
func (e Expression) String() string
String implement the fmt.Stringer interface.
func (*Expression) UnmarshalText ¶
func (e *Expression) UnmarshalText(raw []byte) (err error)
UnmarshalText implements the encoding.TextUnmarshaler interface so an expression can unmarshalled from a JSON object.
type Schedule ¶
type Schedule []Expression
A Schedule represent a list of calendar expressions.
func MustParseSchedule ¶
MustParseSchedule is like ParseSchedule but will panic in case of error.
func ParseSchedule ¶
ParseSchedule parse a list of Expression separated by newlines.
func (Schedule) MarshalText ¶
MarshalText implements the encoding.MarshalText interface.
func (Schedule) Next ¶
Next return the first valid date represented by any expression that is after d.
func (*Schedule) Scan ¶
Scan implements the sql.Scanner interface, which allow to use a Schedule as a database field and scan it.
func (*Schedule) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaller interface, which is used by json.Unmarshal as a fallback when json.Unmarshaler isn't implemented. This is preferred becase the field is a string with a custom parser, which is more semantic to unmarshal with Text rather than JSON.