package te
import "github.com/pnelson/te"
Package te implements temporal expressions.
Index ¶
- func Until(expr Expression, t time.Time) time.Duration
- type Expression
- func Daily() Expression
- func Date(month time.Month, day int) Expression
- func DateRange(m1 time.Month, d1 int, m2 time.Month, d2 int) Expression
- func Day(n int) Expression
- func Except(exprs ...Expression) Expression
- func Hour(hour int) Expression
- func Hourly(n int) Expression
- func Intersect(exprs ...Expression) Expression
- func Minute(min int) Expression
- func Minutely(n int) Expression
- func Month(month time.Month) Expression
- func Parse(s string, loc *time.Location) (Expression, error)
- func Second(sec int) Expression
- func Secondly(n int) Expression
- func Time(hour, min, sec int) Expression
- func TimeRange(h1, m1, s1, h2, m2, s2 int) Expression
- func Union(exprs ...Expression) Expression
- func Weekday(d time.Weekday) Expression
- func Year(year int) Expression
Functions ¶
func Until ¶
func Until(expr Expression, t time.Time) time.Duration
Until returns the duration until the next occurrence of t.
Types ¶
type Expression ¶
Expression represents a temporal expression.
func Daily ¶
func Daily() Expression
Daily returns a temporal expression for daily intervals.
func Date ¶
func Date(month time.Month, day int) Expression
Date returns a temporal expression for a date.
func DateRange ¶
DateRange returns a temporal expression for an inclusive date range.
func Day ¶
func Day(n int) Expression
Day returns a temporal expression for a day of the month. Months without the nth day are ignored. If n is -1, the expression represents the last day of the month. If n is greater than 31 or less than -1, the nil expression is returned.
func Except ¶
func Except(exprs ...Expression) Expression
Except returns a temporal expression that represents exceptions. This expression does not have a next active time. Compose with an intersection expression to represent the difference. This expression is active when none of the given expressions are active.
func Hour ¶
func Hour(hour int) Expression
Hour returns a temporal expression for an hour. If hour is negative or greater than 23, the nil expression is returned.
func Hourly ¶
func Hourly(n int) Expression
Hourly returns a temporal expression for hourly intervals. If n is less than 1 or greater than 12, the nil expression is returned. If n wraps into a new day, the hours begin counting from zero again.
func Intersect ¶
func Intersect(exprs ...Expression) Expression
Intersect returns a temporal expression that represents the intersection of the provided expressions. This expression is active when all of the given expressions are active.
func Minute ¶
func Minute(min int) Expression
Minute returns a temporal expression for a minute. If min is negative or greater than 59, the nil expression is returned.
func Minutely ¶
func Minutely(n int) Expression
Minutely returns a temporal expression for minutely intervals. If n is less than 1 or greater than 30, the nil expression is returned. If n wraps into a new hour, the minutes begin counting from zero again.
func Month ¶
func Month(month time.Month) Expression
Month returns a temporal expression for months of the year.
func Parse ¶
func Parse(s string, loc *time.Location) (Expression, error)
Parse parses the provided string into an Expression.
func Second ¶
func Second(sec int) Expression
Second returns a temporal expression for a second. If sec is negative or greater than 59, the nil expression is returned.
func Secondly ¶
func Secondly(n int) Expression
Secondly returns a temporal expression for secondly intervals. If n is less than 1 or greater than 30, the nil expression is returned. If n wraps into a new minute, the seconds begin counting from zero again.
func Time ¶
func Time(hour, min, sec int) Expression
Time returns a temporal expression for a time.
func TimeRange ¶
func TimeRange(h1, m1, s1, h2, m2, s2 int) Expression
TimeRange returns a temporal expression for an inclusive time range.
func Union ¶
func Union(exprs ...Expression) Expression
Union returns a temporal expression that represents the union of the provided expressions. This expression is active when any of the given expressions are active.
func Weekday ¶
func Weekday(d time.Weekday) Expression
Weekday returns a temporal expression for weekdays.
func Year ¶
func Year(year int) Expression
Year returns a temporal expression for the given year.
Source Files ¶
expressions.go lexer.go parser.go te.go token.go
Directories ¶
Path | Synopsis |
---|---|
cmd | |
cmd/te |
- Version
- v0.0.0-20221112042011-338db5602295 (latest)
- Published
- Nov 12, 2022
- Platform
- linux/amd64
- Imports
- 8 packages
- Last checked
- 1 month ago –
Tools for package owners.