format

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2017 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNumber

func IsNumber(data string) (isNumber bool)

func Number

func Number(v float64, f string) string

Number is used to format a number with a format string. If the format string is empty, then General number formatting is used which attempts to mimic Excel's general formatting.

func NumberGeneric

func NumberGeneric(v float64) string

NumberGeneric formats the number with the generic format which attemps to mimic Excel's general formatting.

func String

func String(v string, f string) string

String returns the string formatted according to the type. TODO: implement if anyone needs this.

Types

type FmtType

type FmtType byte

FmtType is the type of a format token.

const (
	FmtTypeLiteral FmtType = iota
	FmtTypeDigit
	FmtTypeDigitOpt
	FmtTypeComma
	FmtTypeDecimal
	FmtTypePercent
	FmtTypeDollar
	FmtTypeDigitOptThousands
	FmtTypeUnderscore
	FmtTypeDate
	FmtTypeTime
	FmtTypeFraction
)

Format type constants.

type Format

type Format struct {
	Whole         []Token
	Fractional    []Token
	Exponent      []Token
	IsExponential bool
	// contains filtered or unexported fields
}

Format is a parsed number format.

func Parse

func Parse(s string) []Format

func (*Format) AddToken

func (f *Format) AddToken(t FmtType, l []byte)

AddToken adds a format token to the format.

type Lexer

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

func (*Lexer) Lex

func (l *Lexer) Lex(r io.Reader)

type Token

type Token struct {
	Type     FmtType
	Literal  byte
	DateTime string
}

Token is a format token in the Excel format string.

Jump to

Keyboard shortcuts

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