Help us shape the future of Go! Take the 2026 Go Developer Survey

rilltime

package
v0.79.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseCompatibility

func ParseCompatibility(timeRange, offset string) error

Types

type EvalOptions

type EvalOptions struct {
	Now        time.Time
	MinTime    time.Time
	MaxTime    time.Time
	Watermark  time.Time
	FirstDay   int
	FirstMonth int
	// contains filtered or unexported fields
}

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 GrainDurationPart struct {
	Num   int    `parser:"@Number"`
	Grain string `parser:"@Grain"`
}

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 LabeledPointInTime struct {
	Ref       bool `parser:"( @Ref"`
	Earliest  bool `parser:"| @Earliest"`
	Now       bool `parser:"| @Now"`
	Latest    bool `parser:"| @Latest"`
	Watermark bool `parser:"| @Watermark)"`
}

type Offset added in v0.78.0

type Offset struct {
	PreviousPeriod *PreviousPeriod       `parser:"( @@"`
	Grain          *GrainPointInTimePart `parser:"| @@)"`
}

type Ordinal added in v0.60.7

type Ordinal struct {
	Grain string `parser:"@Grain"`
	Num   int    `parser:"@Number"`
}

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 PreviousPeriod struct {
	Prefix string `parser:"@Prefix"`
	Num    int    `parser:"@Number PreviousPeriod"`
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL