duration

package
v3.0.0-rc39 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FmtShortDuration

func FmtShortDuration(d time.Duration) string

func Parse

func Parse(s string) (time.Duration, error)

Parse reads a duration written the way the agent prints one.

The standard library stops at the hour, because a day is not a fixed number of hours everywhere. The agent prints days anyway, in every duration long enough to have one, so it has to read them back: a configuration naming "1d" is naming what "1d" is shown as, and refusing it would be refusing our own output. A day is taken as 24 hours.

Types

type Duration

type Duration struct {
	time.Duration
}

func New

func New(d time.Duration) *Duration

func (Duration) IsZero

func (d Duration) IsZero() bool

func (Duration) MarshalJSON

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

func (Duration) Positive

func (d Duration) Positive() bool

func (*Duration) UnmarshalJSON

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

type Flag

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

Flag adapts a duration to the command line, so an option accepts what the configuration and the agent output accept, the day unit included.

func NewFlag

func NewFlag(p *time.Duration) *Flag

NewFlag returns the command line representation of a duration.

func (*Flag) Set

func (t *Flag) Set(s string) error

func (*Flag) String

func (t *Flag) String() string

func (*Flag) Type

func (t *Flag) Type() string

Jump to

Keyboard shortcuts

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