utils

package
v0.0.0-...-9b92ec5 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Durafmt

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

Durafmt holds the parsed duration and the original input duration.

func Parse

func Parse(dinput time.Duration) *Durafmt

Parse creates a new *Durafmt struct, returns error if input is invalid.

func ParseShort

func ParseShort(dinput time.Duration) *Durafmt

ParseShort creates a new *Durafmt struct, short form, returns error if input is invalid. It's shortcut for `Parse(dur).LimitFirstN(1)`

func ParseString

func ParseString(input string) (*Durafmt, error)

ParseString creates a new *Durafmt struct from a string. returns an error if input is invalid.

func ParseStringShort

func ParseStringShort(input string) (*Durafmt, error)

ParseStringShort creates a new *Durafmt struct from a string, short form returns an error if input is invalid. It's shortcut for `ParseString(durStr)` and then calling `LimitFirstN(1)`

func (*Durafmt) Duration

func (d *Durafmt) Duration() time.Duration

func (*Durafmt) LimitFirstN

func (d *Durafmt) LimitFirstN(n int) *Durafmt

LimitFirstN sets the output format, outputing only first N elements. n == 0 means no limit.

func (*Durafmt) LimitToUnit

func (d *Durafmt) LimitToUnit(unit string) *Durafmt

LimitToUnit sets the output format, you will not have unit bigger than the UNIT specified. UNIT = "" means no restriction.

func (*Durafmt) String

func (d *Durafmt) String() string

String parses d *Durafmt into a human readable duration.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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