duration

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package duration reads and writes the durations of the CLI. A flag that takes a duration accepts a day unit, as in "30d", because policy durations such as a trust expiry are in days. The time package has no day unit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(d time.Duration) string

Format writes a duration that Parse reads back to the same value. It drops zero minutes and seconds, so 48 hours is "48h", not "48h0m0s". Tables use dry/tui/humanize instead.

func Parse

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

Parse reads a duration as time.ParseDuration does, and also accepts a leading day unit: "30d", "1d12h". A day is 24 hours.

func Window

func Window(since, until time.Duration, now time.Time, noun string) (after, before *time.Time, err error)

Window turns the --since and --until flags of a list command into a time range. Both are durations before now, and zero means no bound. after is nil when since is zero, and before is nil when until is zero. More than one list command reads these flags, so they all refuse the same input with the same message. noun names the listed items in the help, as "events".

Types

type Value

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

Value is a pflag value for a duration that accepts the day unit.

func NewValue

func NewValue(target *time.Duration, def time.Duration) *Value

NewValue sets *target to def and returns a flag value that writes to it.

func (*Value) Set

func (v *Value) Set(s string) error

func (*Value) String

func (v *Value) String() string

func (*Value) Type

func (v *Value) Type() string

Jump to

Keyboard shortcuts

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