timespan

package
v0.0.0-...-d841f61 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BySpans

type BySpans []Span

func (BySpans) Len

func (a BySpans) Len() int

func (BySpans) Less

func (a BySpans) Less(i, j int) bool

func (BySpans) Swap

func (a BySpans) Swap(i, j int)

type Span

type Span struct {
	// contains filtered or unexported fields
}

Span represents interval between two times.

func Compact

func Compact(list []Span, diff time.Duration) []Span

Compact merges adjacent spans if end of prev span is less than start of next span or gap less than diff.

func Intersect

func Intersect(left, right Span) *Span

Intersect returns intersect of spans or nil if they don't overlap.

func New

func New(from, to time.Time) Span

New creates new span with given start and end times.

func TypedNew

func TypedNew(from, to time.Time, stype string) Span

TypedNew creates new span of given type with start and end times.

func (*Span) Diff

func (s *Span) Diff(d Span) []Span

Diff returns difference which is in s but not in d.

func (*Span) Duration

func (s *Span) Duration() time.Duration

Duration returns duration of span.

func (*Span) From

func (s *Span) From() time.Time

From returns time at the start of span.

func (*Span) In

func (s *Span) In(v time.Time) bool

In checks if the time moment is in the time span.

func (Span) MarshalJSON

func (s Span) MarshalJSON() ([]byte, error)

func (*Span) To

func (s *Span) To() time.Time

To returns time at the end of span.

func (*Span) Type

func (s *Span) Type() string

Type returns type of span.

func (*Span) UnmarshalJSON

func (s *Span) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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