Documentation ¶
Overview ¶
Package human provides human friendly display formats.
Index ¶
Constants ¶
const MIN_TICKS = 2
Variables ¶
This section is empty.
Functions ¶
func Duration ¶
Duration returns a human friendly description of the given time.Duration.
For example Duration(61*time.Second) returns " 1m 1s".
The length of the string returned is guaranteed to always be 7. A negative duration is treated the same as a positive duration.
func FlotTickMarks ¶
FlotTickMarks returns a struct that will serialize into JSON that Flot expects for a value for tick marks.
If an error occurs the tick list will be empty.
tz is the timezone, and can be the empty string if the default (Eastern) timezone is acceptable.
func ParseDuration ¶
ParseDuration parses a human readable duration. Note that this understands both days and weeks, which time.ParseDuration does not support.
func ToFlot ¶
func ToFlot(ticks []*Tick) []interface{}
ToFlot converts a slice of Ticks into something that will serialize into JSON that Flot consumes, which is an array of 2 element arrays. The 2 element arrays contain an x offset and then a label as a string. For example:
[ [ 0.5, "Saturday" ], [ 1.5, "Sunday" ] ]
Types ¶
type JSONDuration ¶
JSONDuration is a type that implements the json.Unmarshal interface and can be used to parse human readable durations from configuration files.
func (*JSONDuration) String ¶
func (d *JSONDuration) String() string
func (*JSONDuration) UnmarshalJSON ¶
func (d *JSONDuration) UnmarshalJSON(durBytes []byte) error
type Tick ¶
Tick represents a single tick mark.