Documentation
¶
Index ¶
- Constants
- type Calendar
- func (c Calendar) FmtDateFull(t time.Time) (string, error)
- func (c Calendar) FmtDateLong(t time.Time) (string, error)
- func (c Calendar) FmtDateMedium(t time.Time) (string, error)
- func (c Calendar) FmtDateShort(t time.Time) (string, error)
- func (c Calendar) FmtDateTimeFull(t time.Time) (string, error)
- func (c Calendar) FmtDateTimeLong(t time.Time) (string, error)
- func (c Calendar) FmtDateTimeMedium(t time.Time) (string, error)
- func (c Calendar) FmtDateTimeShort(t time.Time) (string, error)
- func (c Calendar) FmtTimeFull(t time.Time) (string, error)
- func (c Calendar) FmtTimeLong(t time.Time) (string, error)
- func (c Calendar) FmtTimeMedium(t time.Time) (string, error)
- func (c Calendar) FmtTimeShort(t time.Time) (string, error)
- func (c Calendar) Format(datetime time.Time, pattern string) (string, error)
- type CalendarDateFormat
- type CalendarDayFormatNameValue
- type CalendarDayFormatNames
- type CalendarFormatNames
- type CalendarFormats
- type CalendarMonthFormatNameValue
- type CalendarMonthFormatNames
- type CalendarPeriodFormatNameValue
- type CalendarPeriodFormatNames
- type Currencies
- type Currency
- type Locale
- type Number
- func (n Number) FmtCurrency(currency string, number float64) (formatted string, err error)
- func (n Number) FmtCurrencyWhole(currency string, number float64) (formatted string, err error)
- func (n Number) FmtNumber(number float64) string
- func (n Number) FmtNumberWhole(number float64) string
- func (n Number) FmtPercent(number float64) string
- type NumberFormats
- type Plural
- type PluralData
- type PluralOperands
- type Symbols
Constants ¶
const ( DateFormatFull = iota DateFormatLong DateFormatMedium DateFormatShort TimeFormatFull TimeFormatLong TimeFormatMedium TimeFormatShort DateTimeFormatFull DateTimeFormatLong DateTimeFormatMedium DateTimeFormatShort )
Standard Formats for Dates, Times & DateTimes These are the options to pass to the Format method.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Calendar ¶
type Calendar struct { Formats CalendarFormats FormatNames CalendarFormatNames }
func (Calendar) FmtDateTimeMedium ¶
type CalendarDateFormat ¶
type CalendarDateFormat struct{ Full, Long, Medium, Short string }
type CalendarDayFormatNameValue ¶
type CalendarDayFormatNameValue struct {
Sun, Mon, Tue, Wed, Thu, Fri, Sat string
}
type CalendarDayFormatNames ¶
type CalendarDayFormatNames struct { Abbreviated CalendarDayFormatNameValue Narrow CalendarDayFormatNameValue Short CalendarDayFormatNameValue Wide CalendarDayFormatNameValue }
type CalendarFormatNames ¶
type CalendarFormatNames struct { Months CalendarMonthFormatNames Days CalendarDayFormatNames Periods CalendarPeriodFormatNames }
type CalendarFormats ¶
type CalendarFormats struct { Date CalendarDateFormat Time CalendarDateFormat DateTime CalendarDateFormat GMT string }
type CalendarMonthFormatNameValue ¶
type CalendarMonthFormatNameValue struct {
Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec string
}
type CalendarMonthFormatNames ¶
type CalendarMonthFormatNames struct { Abbreviated CalendarMonthFormatNameValue Narrow CalendarMonthFormatNameValue Short CalendarMonthFormatNameValue Wide CalendarMonthFormatNameValue }
type CalendarPeriodFormatNameValue ¶
type CalendarPeriodFormatNameValue struct {
AM, PM string
}
type CalendarPeriodFormatNames ¶
type CalendarPeriodFormatNames struct { Abbreviated CalendarPeriodFormatNameValue Narrow CalendarPeriodFormatNameValue Short CalendarPeriodFormatNameValue Wide CalendarPeriodFormatNameValue }
type Currencies ¶
maps a currency code (e.g. "USD") to a Currency
type Number ¶
type Number struct { Symbols Symbols Formats NumberFormats Currencies Currencies }
func (Number) FmtCurrency ¶
FormatCurrency takes a float number and a currency key and returns a string with a properly formatted currency amount with the correct currency symbol. If a symbol cannot be found for the reqested currency, the the key is used instead. If the currency key requested is not recognized, it is used as the symbol, and an error is returned with the formatted string.
func (Number) FmtCurrencyWhole ¶
FormatCurrencyWhole does exactly what FormatCurrency does, but it leaves off any decimal places. AKA, it would return $100 rather than $100.00.
func (Number) FmtNumber ¶
FormatNumber takes a float number and returns a properly formatted string representation of that number according to the locale's number format.
func (Number) FmtNumberWhole ¶
FormatNumberWhole does exactly what FormatNumber does, but it leaves off any decimal places. AKA, it would return 100 rather than 100.01.
func (Number) FmtPercent ¶
FormatPercent takes a float number and returns a properly formatted string representation of that number as a percentage according to the locale's percentage format.
type NumberFormats ¶
type Plural ¶
type Plural struct { Cardinal PluralData Ordinal PluralData }
type PluralData ¶
type PluralData struct { Forms []plural.Form Func func(ops *PluralOperands) plural.Form }
type PluralOperands ¶
type PluralOperands struct { N float64 // absolute value of the source number (integer and decimals) I int64 // integer digits of n V int64 // number of visible fraction digits in n, with trailing zeros W int64 // number of visible fraction digits in n, without trailing zeros F int64 // visible fractional digits in n, with trailing zeros T int64 // visible fractional digits in n, without trailing zeros }
PluralOperands is a representation of http://unicode.org/reports/tr35/tr35-numbers.html#Operands
func NewOperands ¶
func NewOperands(number interface{}) (*PluralOperands, error)
NewOperands returns the operands for number.
func (*PluralOperands) NEqualsAny ¶
func (o *PluralOperands) NEqualsAny(any ...int64) bool
NEqualsAny returns true if o represents an integer equal to any of the arguments.
func (*PluralOperands) NInRange ¶
func (o *PluralOperands) NInRange(from, to int64) bool
NInRange returns true if o represents an integer in the closed interval [from, to].
func (*PluralOperands) NModEqualsAny ¶
func (o *PluralOperands) NModEqualsAny(mod int64, any ...int64) bool
NModEqualsAny returns true if o represents an integer equal to any of the arguments modulo mod.
func (*PluralOperands) NModInRange ¶
func (o *PluralOperands) NModInRange(mod, from, to int64) bool
NModInRange returns true if o represents an integer in the closed interval [from, to] modulo mod.