diff options
author | Sebastian Reichel <sre@ring0.de> | 2017-09-29 22:03:28 +0200 |
---|---|---|
committer | Sebastian Reichel <sre@ring0.de> | 2017-09-29 22:03:28 +0200 |
commit | c41b6053cf403051bb06278acb686072ec58cda4 (patch) | |
tree | f99647214faf9c6ea9994330b0cedee164c9e022 /src | |
parent | b23e071daf5acd6bdd5aac8fa01507f8b3c14f3d (diff) | |
download | serial-barcode-scanner-c41b6053cf403051bb06278acb686072ec58cda4.tar.bz2 |
price: fix parsing of 'XX.Y'
Diffstat (limited to 'src')
-rw-r--r-- | src/price.vapi | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/price.vapi b/src/price.vapi index d744ebc..60a4e78 100644 --- a/src/price.vapi +++ b/src/price.vapi @@ -10,7 +10,10 @@ public struct Price : int { public static Price parse(string data) { if("." in data) { var parts = data.split("."); - return int.parse(parts[0])*100 + int.parse(parts[1]); + if (parts[1].length <= 1) + return int.parse(parts[0])*100 + int.parse(parts[1])*10; + else + return int.parse(parts[0])*100 + int.parse(parts[1].substring(0,2)); } else { return int.parse(data); } |