unit_hr

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Elapsed

func Elapsed(from, to time.Time) (inverted bool, years, months, days, hours, minutes, seconds, nanoseconds int)

func HumanReadableBandwidth

func HumanReadableBandwidth(bytes uint64, delta time.Duration, ext string) string

humanReadableTime: Convert bytes value to unit/sec string using 'delta' to specify the time interval. 'ext' could be 'iB' -> "KiB/s" or B -> "KB/s"

func HumanReadableDate

func HumanReadableDate(duration time.Duration, options ...string) string

TODO humanReadableDate: Convert time.Duration to string human readable version.

func HumanReadableFreq

func HumanReadableFreq(value interface{}, hideUnit ...bool) string

String: Convert frenquency value int64 to string human readable version.

func HumanReadableSize

func HumanReadableSize(size interface{}, opt ...HROptions) string

humanReadableSize: Convert file size (octets/bytes) to human readable version. Note: 'options' in order means => 'useDecimal', 'hideUnit'. 'useDecimal' argument define kilo = 1000 instead of 1024.

func HumanReadableSizeAlt

func HumanReadableSizeAlt(b int64, options ...HROptions) string

HumanReadableSizeAlt: Same as above with an alternative method. Format byte size to human readable format.

func HumanReadableTime

func HumanReadableTime(duration time.Duration, unitSep ...string) string

humanReadableTime: Convert time.Duration to string human readable version.

Types

type HROptions

type HROptions int

options: UNIT_HIDE, UNIT_SHORTEN, UNIT_DECIMAL, UNIT_LOWER

const (
	UNIT_DEFAULT HROptions = 1 << 0
	UNIT_HIDE    HROptions = 1 << 1
	UNIT_SHORTEN HROptions = 1 << 2
	UNIT_DECIMAL HROptions = 1 << 3
	UNIT_LOWER   HROptions = 1 << 4
)

Jump to

Keyboard shortcuts

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