diff options
author | joeybloggs <Dean.Karn@gmail.com> | 2016-08-15 05:41:26 +0300 |
---|---|---|
committer | joeybloggs <Dean.Karn@gmail.com> | 2016-08-15 05:41:26 +0300 |
commit | 15e8d9841c4e3269faa135537ab14e77ae1a0a81 (patch) | |
tree | bd1e150efc7f3b56df3400489d168b21b9ff7913 /eu_ES/eu_ES.go | |
parent | fb2acb93602d54a9be9ff735bcabbe17a66cb876 (diff) |
sure up percent prefix logic, just need to turn prefixes into bytes...
Diffstat (limited to 'eu_ES/eu_ES.go')
-rw-r--r-- | eu_ES/eu_ES.go | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/eu_ES/eu_ES.go b/eu_ES/eu_ES.go index 9fdacb1e..2a7e555c 100644 --- a/eu_ES/eu_ES.go +++ b/eu_ES/eu_ES.go @@ -122,17 +122,29 @@ func (eu *eu_ES) FmtNumber(num float64, v uint64) []byte { func (eu *eu_ES) FmtPercent(num float64, v uint64) []byte { s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) - l := len(s) + len(eu.decimal) - + l := len(s) + len(eu.decimal) + len(eu.group)*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 b := make([]byte, 0, l) for i := len(s) - 1; i >= 0; i-- { if s[i] == '.' { b = append(b, eu.decimal[0]) + inWhole = true + continue } + if inWhole { + if count == 3 { + b = append(b, eu.group[0]) + count = 1 + } else { + count++ + } + } + b = append(b, s[i]) } @@ -140,7 +152,11 @@ func (eu *eu_ES) FmtPercent(num float64, v uint64) []byte { b = append(b, eu.minus[0]) } - b = append(b, eu.Percent[0]) + for j := 2 - 1; j >= 0; j-- { + b = append(b, " "[j]) + } + + b = append(b, eu.percent[0]) // reverse for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { |