diff options
| author | horus_arch | 2018-02-04 15:38:11 +0100 |
|---|---|---|
| committer | horus_arch | 2018-02-04 15:38:11 +0100 |
| commit | fc30c6e856ba8f59cd46c20f76f61f249d8bd88b (patch) | |
| tree | 4afbd0b821d27fc4696b153ca328ee208367ae56 | |
| parent | 0ab75dabe3a9547b8cb716d950d5657eafb28293 (diff) | |
| download | alkobote-fc30c6e856ba8f59cd46c20f76f61f249d8bd88b.tar.gz | |
Adds a utility function to sanitize the price tag.
| -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 + } +} |
