Documentation
¶
Index ¶
- Variables
- type Display
- type FailedParseMoney
- type Humanizer
- func (h *Humanizer) FormatDecimal(decimal decimal.Decimal, currencyCode string, precision int) (string, error)
- func (h *Humanizer) FormatMoney(amount money.Amount, currencyCode string, precision int) (string, error)
- func (h *Humanizer) Formatter(value string, currencyCode string, precision int) (string, error)
- type NumberPattern
- type NumberSystem
- type UnsupportedLocaleError
Constants ¶
This section is empty.
Variables ¶
var NumberSystemMap = map[language.Tag]NumberSystem{}/* 725 elements not displayed */
var SymbolMap = map[string]string{}/* 106 elements not displayed */
Functions ¶
This section is empty.
Types ¶
type Display ¶
type Display uint8
Display represents how the currency should be shown in the formatted output.
const ( // DisplaySymbol shows the currency symbol (e.g., "$" for USD). DisplaySymbol Display = iota // DisplaySymbolCode shows the currency symbol (e.g., "$" for USD) or code if symbol is not available (e.g., "USD" for USD). DisplaySymbolCode // DisplayCode shows the currency code (e.g., "USD"). DisplayCode // DisplayNone shows no currency indicator. DisplayNone )
Constants for Display
type FailedParseMoney ¶ added in v0.1.0
type FailedParseMoney struct { // The original value that failed to parse Value string // The underlying error Err error }
FailedParseAmount represents an error that occurs when parsing a monetary amount fails.
func (FailedParseMoney) Error ¶ added in v0.1.0
func (e FailedParseMoney) Error() string
Error returns a string representation of the error.
type Humanizer ¶
type Humanizer struct { // Locale specifies the language and region for formatting rules Locale language.Tag // NoGrouping disables digit grouping when true (e.g., 1000 vs 1,000) NoGrouping bool // TrimZeros removes trailing zeros in decimal places when true TrimZeros bool // CurrencyDisplay determines how the currency is displayed CurrencyDisplay Display }
Humanizer contains configuration for formatting monetary values.
func (*Humanizer) FormatDecimal ¶ added in v0.1.0
func (h *Humanizer) FormatDecimal(decimal decimal.Decimal, currencyCode string, precision int) (string, error)
FormatDecimal formats a decimal.Decimal value according to locale rules. It takes a Decimal object, currency code, and precision for decimal places. Returns the formatted string and any error that occurred.
func (*Humanizer) FormatMoney ¶ added in v0.1.0
func (h *Humanizer) FormatMoney(amount money.Amount, currencyCode string, precision int) (string, error)
FormatMoney formats a money.Amount value according to locale rules. It takes an Amount object, currency code, and precision for decimal places. Returns the formatted string and any error that occurred.
type NumberPattern ¶
type NumberPattern struct { // Prefix is the string that comes before the number Prefix string // Suffix is the string that comes after the number Suffix string // DecimalSep is the decimal separator character DecimalSep string // GroupSep is the grouping separator character GroupSep string // GroupSizes defines the sizes of digit groups GroupSizes []int // CurrencyAtStart indicates if the currency symbol should appear before the number CurrencyAtStart bool }
NumberPattern holds the formatting pattern for numbers in a specific locale.
type NumberSystem ¶
type UnsupportedLocaleError ¶
UnsupportedLocaleError represents an error that occurs when a locale is not supported.
func (UnsupportedLocaleError) Error ¶
func (e UnsupportedLocaleError) Error() string
Error returns a string representation of the error.