format

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package format provides locale-aware formatting for numbers, currency, and dates. It depends on internal/i18n but has no PDF/layout dependencies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseDate

func ParseDate(dateStr string) (time.Time, error)

ParseDate parses a date string in various formats.

Types

type Formatter

type Formatter struct {
	// contains filtered or unexported fields
}

Formatter handles formatting of numbers, currency, and dates.

func New

func New(i *i18n.I18n, currency string) *Formatter

New creates a new Formatter with the given i18n instance and currency code.

func (*Formatter) FormatCurrency

func (f *Formatter) FormatCurrency(value float64) string

FormatCurrency formats a float as currency with proper separators.

func (*Formatter) FormatDate

func (f *Formatter) FormatDate(dateStr string, longFormat bool) string

FormatDate formats an ISO date string to a localized format. Input: "2026-03-02"; output depends on locale and longFormat flag.

func (*Formatter) FormatDuration

func (f *Formatter) FormatDuration(hours float64) string

FormatDuration formats hours as "HH:MM".

func (*Formatter) FormatFloat

func (f *Formatter) FormatFloat(value float64, decimals int) string

FormatFloat formats a float with the specified number of decimal places.

func (*Formatter) FormatPercent

func (f *Formatter) FormatPercent(value float64) string

FormatPercent formats a percentage value.

func (*Formatter) FormatWorkWeek

func (f *Formatter) FormatWorkWeek(dateStr string) string

FormatWorkWeek formats a date as ISO work-week notation "W.D".

Jump to

Keyboard shortcuts

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