model

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Earliest is the earliest Time representable. Handy for
	// initializing a high watermark.
	Earliest = Time(math.MinInt64)
	// Latest is the latest Time representable. Handy for initializing
	// a low watermark.
	Latest = Time(math.MaxInt64)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Duration

type Duration time.Duration

Duration wraps time.Duration. It is used to parse the custom duration format from YAML. This type should not propagate beyond the scope of input/output processing.

func ParseDuration

func ParseDuration(s string) (Duration, error)

ParseDuration parses a string into a time.Duration, assuming that a year always has 365d, a week always has 7d, and a day always has 24h.

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*Duration) MarshalText

func (d *Duration) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (Duration) MarshalYAML

func (d Duration) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface.

func (*Duration) Set

func (d *Duration) Set(s string) error

Set implements pflag/flag.Value

func (Duration) String

func (d Duration) String() string

func (*Duration) Type

func (d *Duration) Type() string

Type implements pflag.Value

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(bytes []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type Interval

type Interval struct {
	Start, End Time
}

Interval describes an interval between two timestamps.

type Time

type Time int64

Time is the number of milliseconds since the epoch (1970-01-01 00:00 UTC) excluding leap seconds.

func Now

func Now() Time

Now returns the current time as a Time.

func TimeFromUnix

func TimeFromUnix(t int64) Time

TimeFromUnix returns the Time equivalent to the Unix Time t provided in seconds.

func TimeFromUnixNano

func TimeFromUnixNano(t int64) Time

TimeFromUnixNano returns the Time equivalent to the Unix Time t provided in nanoseconds.

func (Time) Add

func (t Time) Add(d time.Duration) Time

Add returns the Time t + d.

func (Time) After

func (t Time) After(o Time) bool

After reports whether the Time t is after o.

func (Time) Before

func (t Time) Before(o Time) bool

Before reports whether the Time t is before o.

func (Time) Equal

func (t Time) Equal(o Time) bool

Equal reports whether two Times represent the same instant.

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Time) String

func (t Time) String() string

String returns a string representation of the Time.

func (Time) Sub

func (t Time) Sub(o Time) time.Duration

Sub returns the Duration t - o.

func (Time) Time

func (t Time) Time() time.Time

Time returns the time.Time representation of t.

func (Time) Unix

func (t Time) Unix() int64

Unix returns t as a Unix time, the number of seconds elapsed since January 1, 1970 UTC.

func (Time) UnixNano

func (t Time) UnixNano() int64

UnixNano returns t as a Unix time, the number of nanoseconds elapsed since January 1, 1970 UTC.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

Jump to

Keyboard shortcuts

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