time

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package time provides time constraints for queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Includes

func Includes(c Constraints, t ...time.Time) bool

Includes determines if the Constraints c include all of t.

Types

type Constraints

type Constraints interface {
	// Exact returns the exact times to query for.
	Exact() []time.Time

	// Ranges returns the time ranges to query for.
	Ranges() []Range

	// Min returns the minimum allowed time to query for. Zero time means this
	// filter is disabled
	Min() time.Time

	// Max returns the maximum allowed time to query for. Zero time means this
	// filter is disabled
	Max() time.Time
}

Constraints are the time constraints for an event query. Methods of Constraints that return non-nil filters must all be fulfilled by an event to be included in the query result. If a filter allows multiple values, the event must match at least one of the values.

func Filter

func Filter(opts ...Option) Constraints

Filter returns Constraints from the given Constraint opts.

func Merge

func Merge(constraints ...Constraints) Constraints

Merge merges the provided Constraints into one.

type Option

type Option func(*constraints)

A Option defines a time constraint.

func After

func After(t time.Time) Option

After returns a Constraint that only allows times that are after at least one of v.

func Before

func Before(t time.Time) Option

Before returns a Constraint that only allows times that are before at least one of v.

func DryMerge

func DryMerge(constraints ...Constraints) []Option

DryMerge returns the Options to merge the provided Constraints.

func Exact

func Exact(t ...time.Time) Option

Exact returns a Constraint that only allows the exact times t.

func InRange

func InRange(r ...Range) Option

InRange returns a Constraint that only allows times in the Ranges r.

func Max

func Max(max time.Time) Option

Max returns a Constraint that only allows times that are <= at least one of v.

func Min

func Min(min time.Time) Option

Min returns a Constraint that only allows times that are >= at least one of v.

type Range

type Range [2]time.Time

Range is a time range.

func (Range) End

func (r Range) End() time.Time

End returns the end of the range (r[1]):

func (Range) Includes

func (r Range) Includes(t time.Time) bool

Includes returns true if t is within the Range r.

func (Range) Start

func (r Range) Start() time.Time

Start returns the start of the range (r[0]):

Jump to

Keyboard shortcuts

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