formatter

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BoolFormats = &entity.FormatConfig{
	Default: "Yes/No",
	Options: []string{
		"Yes/No",
		"True/False",
		"Sí/No",
	},
}

BoolFormats provides boolean display format options.

View Source
var CurrencyFormats = &entity.FormatConfig{
	Default: "$#,##0.00",
	Options: []string{
		"$#,##0.00",
		"€#,##0.00",
		"#,##0.00 USD",
		"#,##0.00 €",
	},
}

CurrencyFormats provides common currency format options.

View Source
var DateFormats = &entity.FormatConfig{
	Default: "DD/MM/YYYY",
	Options: []string{
		"DD/MM/YYYY",
		"MM/DD/YYYY",
		"YYYY-MM-DD",
		"D MMMM YYYY",
		"MMMM D, YYYY",
		"DD MMM YYYY",
	},
}

DateFormats provides common date format options.

View Source
var DateTimeFormats = &entity.FormatConfig{
	Default: "DD/MM/YYYY HH:mm",
	Options: []string{
		"DD/MM/YYYY HH:mm",
		"YYYY-MM-DD HH:mm:ss",
		"D MMMM YYYY, HH:mm",
		"MMMM D, YYYY hh:mm a",
		"DD/MM/YYYY hh:mm a",
	},
}

DateTimeFormats provides common datetime format options.

View Source
var NumberFormats = &entity.FormatConfig{
	Default: "#,##0.00",
	Options: []string{
		"#,##0.00",
		"#,##0",
		"#,##0.000",
		"0.00",
	},
}

NumberFormats provides common number format options.

View Source
var PercentageFormats = &entity.FormatConfig{
	Default: "#,##0.00%",
	Options: []string{
		"#,##0.00%",
		"#,##0%",
		"#,##0.0%",
	},
}

PercentageFormats provides common percentage format options.

View Source
var PhoneFormats = &entity.FormatConfig{
	Default: "+## # #### ####",
	Options: []string{
		"+## # #### ####",
		"(###) ###-####",
		"### ### ####",
		"+##-#-####-####",
	},
}

PhoneFormats provides common phone format options.

View Source
var RUTFormats = &entity.FormatConfig{
	Default: "##.###.###-#",
	Options: []string{
		"##.###.###-#",
		"########-#",
	},
}

RUTFormats provides Chilean RUT format options.

View Source
var TimeFormats = &entity.FormatConfig{
	Default: "HH:mm",
	Options: []string{
		"HH:mm",
		"HH:mm:ss",
		"hh:mm a",
		"hh:mm:ss a",
	},
}

TimeFormats provides common time format options.

Functions

func FormatBool

func FormatBool(b bool, pattern string) string

FormatBool formats a boolean according to the pattern. Pattern format: "TrueValue/FalseValue" (e.g., "Yes/No", "Sí/No")

func FormatNumber

func FormatNumber(n float64, pattern string) string

FormatNumber formats a number according to the pattern and locale. Supports patterns like: #,##0.00, $#,##0.00, etc.

func FormatPhone

func FormatPhone(phone string, pattern string) string

FormatPhone formats a phone number according to the pattern. Pattern uses # as digit placeholder.

func FormatRUT

func FormatRUT(rut string, pattern string) string

FormatRUT formats a Chilean RUT according to the pattern. Pattern uses # as digit placeholder.

func FormatTime

func FormatTime(t time.Time, pattern string) string

FormatTime formats a time value according to the pattern. Supports patterns like: DD/MM/YYYY, HH:mm, MMMM D, YYYY, etc.

Types

This section is empty.

Jump to

Keyboard shortcuts

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