rilltime

package
v0.61.2 Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: Apache-2.0 Imports: 10 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 AbsoluteTime added in v0.60.7

type AbsoluteTime struct {
	ISO string `parser:"@ISOTime"`
	// contains filtered or unexported fields
}

type EvalOptions

type EvalOptions struct {
	Now        time.Time
	MinTime    time.Time
	MaxTime    time.Time
	Watermark  time.Time
	FirstDay   int
	FirstMonth int
}

type Expression

type Expression struct {
	From           *Link          `parser:"@@"`
	To             *Link          `parser:"(To @@)?"`
	Grain          *string        `parser:"(By @Grain)?"`
	AnchorOverride *LabeledAnchor `parser:"('@' @@)?"`
	TimeZone       *string        `parser:"('@' @TimeZone)?"`
	// 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 LabeledAnchor added in v0.60.7

type LabeledAnchor struct {
	Earliest  bool `parser:"( @Earliest"`
	Now       bool `parser:"| @Now"`
	Latest    bool `parser:"| @Latest"`
	Watermark bool `parser:"| @Watermark)"`
}
type Link struct {
	Parts []*LinkPart `parser:"@@ (Of @@)*"`
	// contains filtered or unexported fields
}

Link represents a link of grains specifying the customisable anchors. EG: 7d of -1M : The 7day period of last month. 7day is relative to watermark unless something else is specified.

type LinkPart added in v0.60.7

type LinkPart struct {
	Ordinal       *Ordinal       `parser:"( @@"`
	Anchor        *TimeAnchor    `parser:"| @@"`
	AbsoluteTime  *AbsoluteTime  `parser:"| @@"`
	LabeledAnchor *LabeledAnchor `parser:"| @@)"`
}

type Ordinal added in v0.60.7

type Ordinal struct {
	Grain string `parser:"@Grain"`
	Num   int    `parser:"@Number"`
	// contains filtered or unexported fields
}

Ordinal represent a particular sequence of a grain in the next order grain. EG: W2 - week 2 of the month. EG: M5 - month 5 of the year.

type ParseOptions

type ParseOptions struct {
	DefaultTimeZone  *time.Location
	TimeZoneOverride *time.Location
}

ParseOptions allows for additional options that could probably not be added to the time range itself

type TimeAnchor

type TimeAnchor struct {
	Prefix         *string `parser:"@AnchorPrefix?"`
	Num            *int    `parser:"@Number?"`
	Grain          *string `parser:"( @Grain"`
	PeriodToGrain  *string `parser:"| @PeriodToGrain)"`
	IncludeCurrent bool    `parser:"@Current?"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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