Documentation
¶
Index ¶
- func ParseCompatibility(timeRange, offset string) error
- type EvalOptions
- type Expression
- type GrainDuration
- type GrainDurationPart
- type GrainPointInTime
- type GrainPointInTimePart
- type ISOPointInTime
- type Interval
- type IsoInterval
- type LabeledPointInTime
- type Offset
- type Ordinal
- type OrdinalInterval
- type ParseOptions
- type PeriodToGrainInterval
- type PointInTime
- type PointInTimeWithSnap
- type PreviousPeriod
- type ShorthandInterval
- type StartEndInterval
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseCompatibility ¶
Types ¶
type EvalOptions ¶
type Expression ¶
type Expression struct {
Interval *Interval `parser:"@@"`
AnchorOverrides []*PointInTime `parser:"(As Of @@)*"`
Grain *string `parser:"(By @Grain)?"`
TimeZone *string `parser:"(Tz @Whitespace @TimeZone)?"`
Offset *Offset `parser:"(Offset @@)?"`
// contains filtered or unexported fields
}
func Parse ¶
func Parse(from string, parseOpts ParseOptions) (*Expression, error)
func (*Expression) Eval ¶
func (e *Expression) Eval(evalOpts EvalOptions) (time.Time, time.Time, timeutil.TimeGrain)
type GrainDuration ¶ added in v0.78.0
type GrainDuration struct {
Parts []*GrainDurationPart `parser:"@@ @@*"`
}
type GrainDurationPart ¶ added in v0.78.0
type GrainPointInTime ¶ added in v0.78.0
type GrainPointInTime struct {
Parts []*GrainPointInTimePart `parser:"@@ @@*"`
}
type GrainPointInTimePart ¶ added in v0.78.0
type GrainPointInTimePart struct {
Prefix string `parser:"@Prefix"`
Duration *GrainDuration `parser:"@@"`
}
type ISOPointInTime ¶ added in v0.78.0
type ISOPointInTime struct {
ISO string `parser:"@ISOTime"`
// contains filtered or unexported fields
}
type Interval ¶ added in v0.78.0
type Interval struct {
Shorthand *ShorthandInterval `parser:"( @@"`
PeriodToGrain *PeriodToGrainInterval `parser:"| @@"`
StartEnd *StartEndInterval `parser:"| @@"`
Ordinal *OrdinalInterval `parser:"| @@"`
Iso *IsoInterval `parser:"| @@)"`
}
type IsoInterval ¶ added in v0.78.0
type IsoInterval struct {
Start *ISOPointInTime `parser:"@@"`
End *ISOPointInTime `parser:"((To | '/' | RangeSeparator) @@)?"`
}
IsoInterval is an interval formed by ISO timestamps. Allows for partial timestamps in ISOPointInTime.
type LabeledPointInTime ¶ added in v0.78.0
type Offset ¶ added in v0.78.0
type Offset struct {
PreviousPeriod *PreviousPeriod `parser:"( @@"`
Grain *GrainPointInTimePart `parser:"| @@)"`
}
type OrdinalInterval ¶ added in v0.78.0
type OrdinalInterval struct {
Ordinals []*Ordinal `parser:"@@ (Of @@)*"`
}
OrdinalInterval is an interval formed with a chain of ordinals.
type ParseOptions ¶
type ParseOptions struct {
DefaultTimeZone *time.Location
TimeZoneOverride *time.Location
// TODO: the correct way is perhaps add a keyword in syntax to reference smallest grain.
SmallestGrain timeutil.TimeGrain
}
ParseOptions allows for additional options that could probably not be added to the time range itself
type PeriodToGrainInterval ¶ added in v0.78.0
type PeriodToGrainInterval struct {
PeriodToGrain string `parser:"@PeriodToGrain"`
}
PeriodToGrainInterval is a convenience syntax for specifying <grain> to ref <grain>TD maps to ref/<grain> to ref
type PointInTime ¶ added in v0.78.0
type PointInTime struct {
Points []*PointInTimeWithSnap `parser:"@@ @@*"`
}
type PointInTimeWithSnap ¶ added in v0.78.0
type PointInTimeWithSnap struct {
Grain *GrainPointInTime `parser:"( @@"`
Labeled *LabeledPointInTime `parser:"| @@"`
ISO *ISOPointInTime `parser:"| @@)"`
Snap *string `parser:"(Snap @Grain"`
// A secondary snap after the above snap. This allows specifying a time range bucketed by week but snapped by a higher order grain.
// EG: `Y/Y/W` or `Y/Y/W + 1Y` snaps to the beginning of the 1st week of the year or the beginning of the 1st week of next year (to include the last week of the year)
// `Y/Y` or `Y/Y + 1Y` instead gives 1st day of the year or 1st day of next year.
SecondarySnap *string `parser:"(Snap @Grain)?)?"`
}
type PreviousPeriod ¶ added in v0.78.0
type ShorthandInterval ¶ added in v0.78.0
type ShorthandInterval struct {
Parts []*GrainDurationPart `parser:"@@ @@*"`
}
ShorthandInterval is a convenience shorthand syntax for the advanced StartEndInterval <num><grain> maps to -<num><grain> to ref
type StartEndInterval ¶ added in v0.78.0
type StartEndInterval struct {
Start *PointInTime `parser:"@@"`
End *PointInTime `parser:"To @@"`
}
StartEndInterval is a basic interval with a start and an end.
Click to show internal directories.
Click to hide internal directories.