Documentation
¶
Overview ¶
Package timestring provides some helper functions for displaying time in a human readable way.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Duration ¶ added in v0.2.0
Duration contains the absolute number of each field with all fields adding up to the total duration, so Hours is only the amount of hours to be displayed, unlike (time.Duration).Hours().
func TimeDurationToDuration ¶ added in v0.2.0
TimeDurationToDuration converts a time.Duration to the timestring.Duration for easier display of durations.
type Formatter ¶
type Formatter interface { Option(...FormatterOption) Formatter String(time.Duration) string }
Formatter is the interface that any timestring formatter should match.
var LongProcess Formatter = LongProcessFormatter{}
LongProcess is the ready-to-use Long Process Formatter.
type FormatterOption ¶ added in v0.2.0
type FormatterOption uint
FormatterOption is a list of options that can be applied to the standard formatters.
const ( // NoSpaces is a FormatterOption that tells the formatter to ignore spaces between values. NoSpaces FormatterOption = iota // NoUnitSpaces is a FormatterOption that tells the formatter to ignore spaces betwee values and // units. NoUnitSpaces // Abbreviated is a FormatterOption that tells the formatter to abbreviate the units // (eg. "d" instead of "days"). Abbreviated // ShowMSOnSeconds is a FormatterOption that tells the formatter to show milliseconds when // the value is less than a minute (59 seconds or less). ShowMSOnSeconds )
type LongProcessFormatter ¶
type LongProcessFormatter struct {
// contains filtered or unexported fields
}
LongProcessFormatter is a Long Process Formatter.
It is a formatter that handles processes that would be considered long running, like displaying the uptime of a server or service.
func (LongProcessFormatter) Option ¶ added in v0.2.0
func (a LongProcessFormatter) Option(opts ...FormatterOption) Formatter
Option returns a Long Process Formatter with the applied options.