budget-go/database/model/transaction_formater.go
Simon Vieille 96c3c822cd
fix importation of transaction (type of request)
add importer for Banque Populaire transactions
2025-04-09 08:51:26 +02:00

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)
}