Documentation ¶
Overview ¶
Package gxtime encapsulates some golang.time functions refers from https://github.com/senseyeio/spaniel/blob/master/interval.go
Package gxtime encapsulates some golang.time functions refer from https://github.com/senseyeio/spaniel/blob/master/timespan.go
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EndPoint ¶
type EndPoint struct { Element time.Time Type EndPointType }
EndPoint represents an extreme of an interval, and whether it is inclusive or exclusive (Closed or Open)
type EndPointType ¶
type EndPointType int
EndPointType represents whether the start or end of an interval is Closed or Open.
const ( // Open means that the interval does not include a value Open EndPointType = iota // Closed means that the interval does include a value Closed )
type IntersectionHandlerFunc ¶
type IntersectionHandlerFunc func(intersectingEvent1, intersectingEvent2, intersectionSpan Span) Span
IntersectionHandlerFunc is used by IntersectionWithHandler to allow for custom functionality when two spans intersect. It is passed the two spans that intersect, and span representing the intersection.
type Span ¶
type Span interface { Start() time.Time StartType() EndPointType End() time.Time EndType() EndPointType }
Span represents a basic span, with a start and end time.
type Spans ¶
type Spans []Span
Spans represents a list of spans, on which other functions operate.
func (Spans) Intersection ¶
Intersection returns a list of Spans representing the overlaps between the contained spans. For example, given a list [A,B] where A and B overlap, a list [C] would be returned, with the span C covering the intersection of A and B.
func (Spans) IntersectionWithHandler ¶
func (s Spans) IntersectionWithHandler(intersectHandlerFunc IntersectionHandlerFunc) Spans
IntersectionWithHandler returns a list of Spans representing the overlaps between the contained spans. For example, given a list [A,B] where A and B overlap, a list [C] would be returned, with the span C covering the intersection of the A and B. The provided handler function is notified of the two spans that have been found to overlap, and the span representing the overlap.
func (Spans) Union ¶
Union returns a list of Spans representing the union of all of the spans. For example, given a list [A,B] where A and B overlap, a list [C] would be returned, with the span C spanning both A and B.
func (Spans) UnionWithHandler ¶
func (s Spans) UnionWithHandler(unionHandlerFunc UnionHandlerFunc) Spans
UnionWithHandler returns a list of Spans representing the union of all of the spans. For example, given a list [A,B] where A and B overlap, a list [C] would be returned, with the span C spanning both A and B. The provided handler is passed the source and destination spans, and the currently merged empty span.
type TimeSpan ¶
type TimeSpan struct {
// contains filtered or unexported fields
}
TimeSpan represents a simple span of time, with no additional properties. It should be constructed with NewEmpty.
func New ¶
New creates a span with a start and end time, with the types set to [] for instants and [) for spans.
func NewInstant ¶
NewInstant creates a span with just a single time.
func NewWithTypes ¶
func NewWithTypes(start, end time.Time, startType, endType EndPointType) *TimeSpan
NewWithTypes creates a span with just a start and end time, and associated types, and is used when no handlers are provided to Union or Intersection.
func (TimeSpan) EndType ¶
func (ts TimeSpan) EndType() EndPointType
EndType returns the type of the end of the interval (Closed in this case)
func (TimeSpan) StartType ¶
func (ts TimeSpan) StartType() EndPointType
StartType returns the type of the start of the interval (Open in this case)
type UnionHandlerFunc ¶
UnionHandlerFunc is used by UnionWithHandler to allow for custom functionality when two spans are merged. It is passed the two spans to be merged, and span which will result from the union.