diff options
Diffstat (limited to 'utilities.go')
| -rw-r--r-- | utilities.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/utilities.go b/utilities.go new file mode 100644 index 0000000..02538fa --- /dev/null +++ b/utilities.go @@ -0,0 +1,28 @@ +package main + +import ( + "strings" +) + +func sanitize_price(price string) int { + multiply_by_100 := false + + price = strings.TrimSpace(price) + + price = strings.TrimPrefix(price, "€") + price = strings.TrimSpace(price) + + price = strings.TrimSuffix(price, "€") + price = strings.TrimSpace(price) + + /* + Extracts the third last char and checks if it's a ",". + */ + //if ( rune(",") == []rune(price)[-3]) + c := string(price[len(price)-3:]) + c = string(c[0:1]) + + if "," == c { + multiply_by_100 = true + } +} |
