timeutils

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: MIT Imports: 4 Imported by: 0

README

sylr.dev/timeutils Go Reference codecov

Library with utilities for Time related operations.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interval

type Interval struct {
	Start time.Time
	End   time.Time
}

Interval defines a period that is constained by two time boundaries, a start time that is part of the interval and an end time which is excluded from the interval.

  |----------i----------[
start                  end

func NewInterval

func NewInterval(start, end time.Time) Interval

func (Interval) Contiguous

func (i Interval) Contiguous(input Interval) bool

Contiguous tests if input is contiguous to Interval.

interval:           |----------i----------[
input:                                    |--input--[
input:    |--input--[

func (Interval) Duration

func (i Interval) Duration() time.Duration

func (Interval) Engulf

func (i Interval) Engulf(input Interval) bool

Engulf tests that the input interval is within Interval. Returns true also if both intervals are equal.

interval:      |------------i------------[
input:                |---input---[

func (Interval) Equal

func (i Interval) Equal(input Interval) bool

Equal tests that the input interval has the time time boundaries as Interval.

interval:      |------------i------------[
input:         |----------input----------[

func (Interval) Include

func (i Interval) Include(input time.Time) bool

Include tests if input time is within the interval. Note that if input is

equal to the end of the interval, then false is returned.

interval:      |------------i------------[
input:              |

func (Interval) Overlap

func (i Interval) Overlap(input Interval) bool

Overlap tests if input overlaps with Interval. Sharing opposite time boundaries is not enough to overlap.

interval:      |------------i------------[
input:                          |----input---[
input:    |----input----[
input:             |---input---[
input:      |-------------input-------------[

func (Interval) String

func (i Interval) String() string

func (Interval) Sub

func (i Interval) Sub(input Interval) Intervals

Sub substracts input to Interval.

interval:      |------------i------------[
input:                    |------input------[
output:        |----i'----[
input:                 |--input--[
output:        |--i'---[         |--i"---[

type Intervals

type Intervals []Interval

Intervals is a slice of Interval.

func (Intervals) Equal

func (is Intervals) Equal(input Intervals) bool

Equal tests that the input Intervals contains the same intervals as Intervals in no particular order.

func (Intervals) String

func (is Intervals) String() string

String returns a string representation of Intervals.

func (Intervals) Swap

func (is Intervals) Swap(i, j int)

Swap swaps the intervals with indexes i and j.

Jump to

Keyboard shortcuts

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