summaryrefslogtreecommitdiff
path: root/format.go
diff options
context:
space:
mode:
Diffstat (limited to 'format.go')
-rw-r--r--format.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/format.go b/format.go
index 3a4f21b..f9e689d 100644
--- a/format.go
+++ b/format.go
@@ -25,16 +25,17 @@ func fill(s string, n int) string {
return s + strings.Repeat("0", n-len(s))
}
+// Country settings
type Country struct {
- Thousend, Decimal rune
- Block, Fraction int
+ Thousend, Decimal rune // delimiter rune
+ Block, Fraction int // block length
}
const (
- Space = '\u0020'
- Apostrophe = '\u0027'
- Comma = '\u002c'
- FullStop = '\u002e'
+ Space = ' '
+ Apostrophe = '\''
+ Comma = ','
+ FullStop = '.'
MiddleDot = '\u00b7'
ThinSpace = '\u2009'
NoBreakSpace = '\u202f'
@@ -49,11 +50,13 @@ var (
IR = Country{Space, MiddleDot, 3, 2}
CH = Country{Apostrophe, FullStop, 3, 2}
IT = Country{DotAbove, Comma, 3, 2}
- CN = Country{Comma, FullStop, 4, 2}
+ CN = Country{Comma, FullStop, 4, 2} // 10000 based
)
+// DefaultFormat is europeian SI format
var DefaultFormat = FR
+// Format float value as localized representation
func (c Country) Format(v float64) string {
s := strconv.FormatFloat(v, 'f', -1, 64)
neg := strings.HasPrefix(s, "-")