|
4 | 4 | "errors"
|
5 | 5 | "fmt"
|
6 | 6 | "strconv"
|
| 7 | + "strings" |
7 | 8 | )
|
8 | 9 |
|
9 | 10 | // Singletons matching Vitodata™ types.
|
@@ -56,19 +57,23 @@ func (v *VitodataDouble) Human2VitodataValue(value string) (string, error) {
|
56 | 57 | if err != nil {
|
57 | 58 | return "", err
|
58 | 59 | }
|
59 |
| - return strconv.FormatFloat(num, 'f', -1, 64), nil |
| 60 | + return strings.Replace(strconv.FormatFloat(num, 'f', -1, 64), ".", ",", 1), nil |
60 | 61 | }
|
61 | 62 |
|
62 | 63 | // Vitodata2HumanValue checks that the value is a float number and
|
63 | 64 | // returns it after reformatting.
|
64 | 65 | func (v *VitodataDouble) Vitodata2HumanValue(value string) (string, error) {
|
65 |
| - return v.Human2VitodataValue(value) |
| 66 | + num, err := strconv.ParseFloat(strings.Replace(value, ",", ".", 1), 64) |
| 67 | + if err != nil { |
| 68 | + return "", err |
| 69 | + } |
| 70 | + return strconv.FormatFloat(num, 'f', -1, 64), nil |
66 | 71 | }
|
67 | 72 |
|
68 | 73 | // Vitodata2NativeValue extract the number from the passed string and
|
69 | 74 | // returns it as a float64.
|
70 | 75 | func (v *VitodataDouble) Vitodata2NativeValue(value string) (interface{}, error) {
|
71 |
| - num, err := strconv.ParseFloat(value, 64) |
| 76 | + num, err := strconv.ParseFloat(strings.Replace(value, ",", ".", 1), 64) |
72 | 77 | if err != nil {
|
73 | 78 | return nil, err
|
74 | 79 | }
|
|
0 commit comments