timeframe

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Forever = Timeframe{}

A timeframe with no bounds, representing all of time

Functions

This section is empty.

Types

type Timeframe

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

A timeframe

func New

func New(f, t time.Time) Timeframe

Create a timeframe

func NewSince

func NewSince(f time.Time) Timeframe

Create a timeframe from the specified time to +inf

func NewUntil

func NewUntil(t time.Time) Timeframe

Create a timeframe from -inf to the specified time

func Parse

func Parse(s string) (Timeframe, error)

Parse a timeframe from its encoded format

func (Timeframe) CompareDuration

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

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

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

func (t Timeframe) Format(layout string) string

func (Timeframe) IsFinite

func (t Timeframe) IsFinite() bool

Is a timeframe finite (is bounded)

func (Timeframe) MarshalColumn

func (t Timeframe) MarshalColumn() ([]byte, error)

func (Timeframe) String

func (t Timeframe) String() string

func (*Timeframe) UnmarshalColumn

func (t *Timeframe) UnmarshalColumn(text []byte) error

Jump to

Keyboard shortcuts

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