filter

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Infinite = Timeframe{}

A timeframe with no bounds, representing all time

View Source
var ZeroRange = Range{}

Functions

This section is empty.

Types

type Filter

type Filter struct {
	Limit     Range
	Order     Order
	Timeframe Timeframe
	Params    map[string]interface{}
}

func New

func New(opts ...Option) Filter

func (Filter) Param added in v1.5.0

func (f Filter) Param(n string) (interface{}, bool)

type Option

type Option func(Filter) Filter

func WithLimit

func WithLimit(r Range) Option

func WithOrder added in v1.3.0

func WithOrder(o Order) Option

func WithTimeframe added in v1.3.0

func WithTimeframe(t Timeframe) Option

type Order added in v1.3.0

type Order int
const (
	Ascending Order = iota
	Descending
)

type Range

type Range struct {
	Offset int `json:"offset"`
	Length int `json:"length"`
}

type Timeframe added in v1.3.0

type Timeframe struct {
	Since *time.Time `json:"since"`
	Until *time.Time `json:"until"`
}

A timeframe

func NewSince added in v1.3.0

func NewSince(f time.Time) Timeframe

Create a timeframe from the specified time to +inf

func NewTimeframe added in v1.3.0

func NewTimeframe(f, t time.Time) Timeframe

Create a timeframe

func NewUntil added in v1.3.0

func NewUntil(t time.Time) Timeframe

Create a timeframe from -inf to the specified time

func (Timeframe) CompareDuration added in v1.3.0

func (t Timeframe) CompareDuration(d time.Duration) int

CompareDuration compares the duration between t.Since and t.Until with the given duration

func (Timeframe) Contains added in v1.3.0

func (t Timeframe) Contains(a time.Time) bool

Determine if the timeframe contains the specified time. Timeframes are inclusive on the lower bound and exclusive on the upper bound.

func (Timeframe) Duration added in v1.3.0

func (t Timeframe) Duration() time.Duration

What is the duration of the timeframe. If a timeframe is not bounded on both ends, the duration is infinite, which is expressed as a negative value. If Until is before Since, the value will also be negative, this is a logically invalid state that is interpreted as the timeframe being unbounded.

func (Timeframe) Format added in v1.3.0

func (t Timeframe) Format(layout string) string

func (Timeframe) IsFinite added in v1.3.0

func (t Timeframe) IsFinite() bool

Is a timeframe finite (is bounded)

func (Timeframe) String added in v1.3.0

func (t Timeframe) String() string

Jump to

Keyboard shortcuts

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