formatutil

package
v0.0.0-...-3518944 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2017 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Date

func Date(lang i18n.Languager, t time.Time, style DateStyle) string

Date formats the date part of the given time.Time according to the given DateStyle.

func Duration

func Duration(lang i18n.Languager, d time.Duration) string

func Number

func Number(lang i18n.Languager, number interface{}) (string, error)

func RelativeDate

func RelativeDate(lang i18n.Languager, t time.Time, style DateStyle) string

RelativeDate works like Date, but uses relative names when possible. e.g. in English "yesterday", "today" and "tomorrow" are the available relative names, but other languages might have more or none of them.

func Size

func Size(s uint64) string

FormatSize returns the given size in bytes formatted as a human readable string. The precision and unit will vary depending on the size.

func Time

func Time(lang i18n.Languager) string

func TimeSince

func TimeSince(lang i18n.Languager, t time.Time) string

Types

type DateStyle

type DateStyle int

DateStyle represents a style for formatting a date. All the examples use January 2nd, 2006. A _ before a number represents a space that might be replaced by a digit if the following number has two digits.

const (
	// 02/01/06
	DateStyleShort DateStyle = iota - 1
	// Jan 2, 2006
	DateStyleMedium
	// January 2, 2006
	DateStyleLong
)

Jump to

Keyboard shortcuts

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