format

package
v0.0.0-...-91c5940 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2017 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STATE_DEFAULT int = iota
	STATE_QUOTED_STRING
	STATE_YEAR
	STATE_MONTH
	STATE_DAY
	STATE_HOUR_h // 0-12
	STATE_HOUR_H // 0-23
	STATE_MINUTE
	STATE_SECOND
	STATE_FRACTION_SECOND_f
	STATE_FRACTION_SECOND_F
	STATE_AM_PM
	STATE_DATE_SEPARATOR
	STATE_TIME_SEPARATOR
)

Variables

This section is empty.

Functions

func Append_formatted_date

func Append_formatted_date(dest []byte, dt time.Time, format_string []byte, langinfo *lang.Langinfo) []byte

Append_formatted_date appends date dt, formatted by format_string.

Types

type Numberfmt

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

Numberfmt is the object that is used to output a number with a format string. It contains information from format string, like digit placeholders count. It also contains the number as string, before formatting.

Number formatting is made in two passes.
  - First pass: Get_format_info() parses the format string to count the number of placeholders. Result is put in Numberfmt object.
  - Fill_int64(), Fill_float64(), or Fill_MyQuad() puts the number to format in Numberfmt as plain string.
  - Set_langinfo() puts decimal point symbol and group separator symbol in Numberfmt.
  - Second pass: Append_formatted_number() makes a second parsing to replace placeholders by digits, writing result into target byte slice.

Normally, errors occur only when number is in exponent notation, or Nan or Infinity. But this should not happen with the numbers being in SQL INT, BIGINT, FLOAT or NUMERIC range.

func (*Numberfmt) Append_formatted_number

func (nbfmt *Numberfmt) Append_formatted_number(dest []byte, format_string []byte) (dst []byte, err error)

func (*Numberfmt) Fill_MyQuad

func (nbfmt *Numberfmt) Fill_MyQuad(n *quad.MyQuad)

func (*Numberfmt) Fill_float64

func (nbfmt *Numberfmt) Fill_float64(n float64)

func (*Numberfmt) Fill_int64

func (nbfmt *Numberfmt) Fill_int64(n int64)

func (*Numberfmt) Get_format_info

func (nbfmt *Numberfmt) Get_format_info(format_string []byte)

Get_format_info counts the number of digit placeholders.

func (*Numberfmt) Set_langinfo

func (nbfmt *Numberfmt) Set_langinfo(langinfo *lang.Langinfo)

func (*Numberfmt) String

func (nbfmt *Numberfmt) String() string

Jump to

Keyboard shortcuts

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