31 lines
559 B
Go
31 lines
559 B
Go
package model
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"golang.org/x/text/encoding/charmap"
|
|
"golang.org/x/text/transform"
|
|
)
|
|
|
|
func ToFloat(value string) float64 {
|
|
value = strings.ReplaceAll(value, ",", ".")
|
|
v, _ := strconv.ParseFloat(value, 64)
|
|
|
|
return v
|
|
}
|
|
|
|
func ToDate(value, format string) time.Time {
|
|
v, _ := time.Parse(format, value)
|
|
|
|
return v
|
|
}
|
|
|
|
func ToUTF8(input string) string {
|
|
reader := transform.NewReader(strings.NewReader(input), charmap.ISO8859_1.NewDecoder())
|
|
decoded, _ := ioutil.ReadAll(reader)
|
|
|
|
return string(decoded)
|
|
}
|