clockflag

package
v0.0.0-...-d3da680 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 4 Imported by: 26

Documentation

Index

Constants

View Source
const DurationHelp = "A duration string is a sequence of <number><unit> such as 2h15m. " +
	"Supported units are 'ns', 'us'/'µs', 'ms', 's', 'm', and 'h'."

DurationHelp is generic Duration help.

Variables

This section is empty.

Functions

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats a time.Duration into a string that can be parsed with ParseDuration.

Types

type Duration

type Duration time.Duration

Duration is a Flag- and JSON-compatible Duration value.

func ParseDuration

func ParseDuration(v string) (Duration, error)

ParseDuration parses a clockflag Duration from a string. This is basically a typed fall-through to time.ParseDuration.

func (Duration) IsZero

func (d Duration) IsZero() bool

IsZero tests if this Duration is the zero value.

func (Duration) MarshalJSON

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

MarshalJSON implements json.Marshaler.

Marshals a Duration into a duration string.

func (*Duration) Set

func (d *Duration) Set(value string) (err error)

Set implements flag.Value.

func (*Duration) String

func (d *Duration) String() string

func (*Duration) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler.

Unmarshals a JSON entry into the underlying type. The entry is expected to contain a string corresponding to one of the enum's keys.

type Time

type Time time.Time

Time is a flag- and JSON-compatible Time which parses from RFC3339 strings.

func (Time) Equal

func (t Time) Equal(o Time) bool

func (Time) MarshalJSON

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

MarshalJSON implements json.Marshaler.

Marshals a Time into an RFC3339 time string.

func (*Time) Set

func (t *Time) Set(value string) error

Set implements flag.Value.

func (*Time) String

func (t *Time) String() string

func (Time) Time

func (t Time) Time() time.Time

Time returns the Time value associated with this Time.

func (*Time) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler.

Unmarshals a JSON entry into the underlying type. The entry is expected to contain a string corresponding to one of the enum's keys.

Jump to

Keyboard shortcuts

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