i18ndate

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2019 License: GPL-3.0 Imports: 3 Imported by: 0

README

godate-i18n

Golang date internationalization library

Documentation

Index

Constants

View Source
const (
	ShortDay = 1 << iota
	LongDay
	DayNumber
	ShortMonth
	LongMonth
	MonthNumber
	Year

	Time // Return also the time
)

These constants permit to specify which fields (and their string representation !) the user wants

View Source
const (
	BasicDate     = LongDay | DayNumber | LongMonth | Year
	NumericalDate = DayNumber | MonthNumber | Year
)

Constants defining usual representations

View Source
const (
	PadNumerics = 1 << iota // When used with `NumericalDate` flag day and month will be padded with `0` if necessary
)

Options that trigger special behaviors when used in conjunction with others flags

Variables

This section is empty.

Functions

This section is empty.

Types

type Lang

type Lang string

Lang reprensents an available language

type LangDay

type LangDay string

LangDay is a string representing a day in a foreign language

type LangMonth

type LangMonth string

LangMonth is a string representing a day in a foreign language

type Translator

type Translator struct {
	DateTimeSeparator string
	Lang              Lang
	Days              []LangDay
	Months            []LangMonth
}

Translator is the structure containing the months and days slices for a given language

func NewEnglishTranslator

func NewEnglishTranslator() *Translator

NewEnglishTranslator returns a *Translator with the english days and months

func NewFrenchTranslator

func NewFrenchTranslator() *Translator

NewFrenchTranslator returns a *Translator with the french days and months

func NewTranslator

func NewTranslator(lang string) (*Translator, error)

NewTranslator returns a translator corresponding to a given language or an error if this language is unavailable

func (*Translator) Translate

func (tr *Translator) Translate(time time.Time, pattern int) (date string)

Translate takes a time.Time in parameter and returns a formatted string according to the provided pattern (for instance BasicDate)

Jump to

Keyboard shortcuts

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